proxychains
V2EX  ›  问与答

请教一个 nginx 反代后 301 的问题

  •  
  •   proxychains · Aug 18, 2022 · 853 views
    This topic created in 1368 days ago, the information mentioned may be changed or developed.

    源服务地址 10.1.1.2:9090 , 进入这个路径后会 301 到 10.1.1.2:9090/index/ 想要将该服务 url 路径修改为 10.1.1.2/service/ . 访问反代后的路径由于源站会 301 跳转, 所以网页直接跳到 10.1.1.2/index 界面, 404 了. 请问这种有遇到过没, google 搜到的 proxy_redirect 方案试了貌似没生效.

    nginx 配置

    server {
    	listen 80;
            server_name _;
            location /service/ {
        	proxy_pass http://10.1.1.2:9090/;
            proxy_set_header HOST $HOST;
    	proxy_set_header X-Real_IP $remote_addr;
    	proxy_set_header Accept-Encoding "";
        }
    }
    
    jifengg
        1
    jifengg  
       Aug 19, 2022   ❤️ 1
    既然你已经知道 :9090/ 会 301 到 :9090/index/,那么你的 proxy_pass 直接配置 http://10.1.1.2:9090/index/ 就好了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   840 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:00 · PVG 05:00 · LAX 14:00 · JFK 17:00
    ♥ Do have faith in what you're doing.