嘿,我已经阅读了有关此问题的5个与nginx相关的不同问题。我使配置工作,然后重新启动服务并收到太多重定向错误。我真想调试一下
客户端应用程序运行正常,但是当我发布到/ api端点时,重定向太多。我应该提到也许我的主机文件中将我的IP列入了白名单,以读取到mydomain
我的配置看起来像
server {
listen 80;
server_name 00.000.00.000; #IP address
return 301 https://my.domain$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl https default_server;
# ssl security config
# lets encrypt manage by certbot
index index.html index.htm index.nginx-debian.html;
server_name 00.000.00.000 my.domain;
root /var/www/html;
location / {
try_files $uri $uri/ /index.html;
}
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://HTTPAPIbackend;
proxy_redirect off;
proxy_set_header Host $host;
}
}
upstream HTTPAPIbackend {
server my.domain max_fails=3 fail_timeout -60s;
}
有什么想法吗?