我已经设置了 Nginx 反向代理,但出现错误。我不知道为什么会这样,我的配置文件有问题。
此页面无法正常工作 - 重定向次数过多。ERR_TOO_MANY_REDIRECTS
这是 Certbox 生成的我的配置文件
server {
server_name base.4evergaming.com;
error_page 403 https://www.4evergaming.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.1.10;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/base.4evergaming.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/base.4evergaming.com/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
}
server {
if ($host = base.4evergaming.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name base.4evergaming.com;
return 404; # managed by Certbot
}
答案1
尝试以下配置
server {
server_name base.4evergaming.com;
error_page 403 https://www.4evergaming.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
proxy_pass http://192.168.1.10:80;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/base.4evergaming.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/base.4evergaming.com/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
}
server {
listen 80;
listen [::]:80;
server_name base.4evergaming.com;
return 404; # managed by Certbot
}