You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx无法正确重定向至指定路径问题求助

Hey there, let's figure out why your Nginx redirects aren't working as expected. Looking at your config, I can spot a few potential issues and fixes to try:

1. Incomplete location / Configuration

Your default location / block is cut off, which will definitely cause unexpected behavior for requests that don't match /auth-foo. Here's a complete, basic setup you can adapt for your backend:

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://your-backend-ip:your-port; # Replace with your actual backend address
    # Fix backend redirects that might point to internal IPs
    proxy_redirect off;
    proxy_set_header X-Forwarded-Proto $scheme;
}
2. Trailing Slash Missing in /auth-foo proxy_pass

Right now, your proxy_pass http://192.168.52.89:2085; doesn't have a trailing slash. This means Nginx will pass the full /auth-foo path to your backend. For example, a request to https://192.168.52.89/auth-foo/login gets sent to http://192.168.52.89:2085/auth-foo/login.

If your backend expects the path without /auth-foo (like just /login), add the trailing slash:

location /auth-foo {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass_header Set-Cookie;
    proxy_pass http://192.168.52.89:2085/; # Notice the trailing slash here
}
3. Outdated SSL Protocols

Your config includes deprecated TLS versions (TLSv1 and TLSv1.1), which are insecure and might cause compatibility issues with modern clients. Update this line to use only secure protocols:

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5; # Add this to enforce strong cipher suites
4. Debugging Steps to Verify Fixes
  • Validate your config: Run sudo nginx -t to check for syntax errors. It'll tell you exactly where things are broken if there's an issue.
  • Check error logs: Look at /var/log/nginx/error.log (default path) for clues about failed redirects or proxy issues.
  • Test with curl: Use curl -v https://192.168.52.89/auth-foo to see the full request/response chain and confirm where the redirect is going wrong.

内容的提问来源于stack exchange,提问作者Ayo K

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:10:00