【发布时间】:2019-02-06 15:10:36
【问题描述】:
按照this 的回答,我的 nginx 服务器设置如下:
server {
server_name portal.productive.city www.portal.productive.city;
root /www/Productive-Website/my-app/build;
index index.html index.htm;
rewrite ^/(.*)/$ $1 permanent;
location / {
try_files $uri?$args $uri/ $uri.html?$args /index.html?$args;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/portal.productive.city/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/portal.productive.city/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
我的另一台服务器(在同一个文件中)(由lets-encrypt 创建)是:
server {
if ($host = www.portal.productive.city) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = portal.productive.city) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name portal.productive.city www.portal.productive.city;
return 404; # managed by Certbot
}
当我尝试访问:www.portal.productive.city 或 www.portal.productive.city/signin 时,我收到 500 内部服务器错误
我的错误日志文件如下所示:
2018/08/31 14:43:08 [错误] 29581#29581: *25 重写或内部 内部重定向到“/index.html”时的重定向循环, 客户端:74.105.149.67,服务器:portal.productive.city,请求:“GET / HTTP/1.1”,主机:“www.portal.productive.city”
2018/08/31 14:43:08 [错误] 29581#29581: *26 重写或内部重定向周期 while 内部重定向到“/index.html”,客户端:74.105.149.67, 服务器:portal.productive.city,请求:“GET /favicon.ico HTTP/1.1”, 主持人:“www.portal.productive.city”,推荐人: "https://www.portal.productive.city/"
favicon.ico 存在于path/to/repo/build 下
编辑:我清除了缓存并重组了服务器,如下所示:
server {
server_name portal.productive.city www.portal.productive.city;
root /www/Productive-Website/my-app/build;
index index.html index.htm;
location / {
try_files $uri?$args $uri/ $uri.html?$args /index.html?$args;
}
listen 80;
if ($scheme != "https") {
return 301 https://$host$request_uri?$args;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/portal.productive.city/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/portal.productive.city/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
错误文件现在是:
2018/08/31 15:17:54 [错误] 29789#29789: *17 重写或内部 内部重定向到“/index.html”时的重定向循环, 客户端:74.105.149.67,服务器:portal.productive.city,请求:“GET /? HTTP/1.1”,主机:“www.portal.productive.city”
2018/08/31 15:17:54 [错误] 29789#29789: *18 重写或内部重定向周期 while 内部重定向到“/index.html”,客户端:74.105.149.67, 服务器:portal.productive.city,请求:“GET /favicon.ico HTTP/1.1”, 主持人:“www.portal.productive.city”,推荐人: "https://www.portal.productive.city/?"
【问题讨论】:
标签: nginx