【发布时间】:2018-06-04 15:23:18
【问题描述】:
自从我在启用站点/默认配置中通过 SSL 设置 HTTPS 以来,Nginx 正在从 /usr/share/www/html 而不是 /var/www/html 读取。我的任何文件中都没有对/usr/.../html 的引用(当我使用grep -r 时),所以我不知道为什么会发生这种情况。
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name MY_WEBSITE.TLD; # Before you ask, yes
return 302 https://$server_name$request_uri;
root /var/www/html;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
index index.html index.htm index.nginx-debian.html index.php;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
显然我已经定义了根。为什么它不起作用?
【问题讨论】:
-
您是否尝试过在 SSL 配置部分定义根?
-
哪个是ssl配置部分?你的意思是第二个服务器块?如果是这样,是的,我有。
-
是的,我就是这个意思。这个安装有多少个站点?您可以在“http”部分设置 root ... 这样做吗?我运行了一个小 nGinx,但没有用它做太多的服务器配置......对不起。
-
只有一个域。我尝试在 http 部分设置它...但现在我得到一个 403 禁止错误...
-
两个容器/部分都需要 server_name 吗?
标签: php ssl nginx https config