开发者社区 问答 正文

nginx 代理改变请求 400 请求报错 

各位好:
我想将http://192.168.0.1/Web/Test/test.html用nginx代理成:http://192.168.0.2/Web/hello.html。
我在192.168.0.1的nginx中做了如下的配置后:
location /test.html {
    index /hello.html;
    proxy_pass http://192.168.0.2;
}
代理后的结果是无法将test.html 代理成:hello.html.
各位大侠们,怎么处理???

展开
收起
kun坤 2020-05-29 17:31:13 540 分享 版权
1 条回答
写回答
取消 提交回答
  • location /Web/Test/test.html {
        return 301 http://192.168.0.2/Web/hello.html;
    }
    试试 ######

    引用来自“hylent”的答案

    location /Web/Test/test.html {
        return 301 http://192.168.0.2/Web/hello.html;
    }
    试试 可以用了。呵呵!!谢谢!!!301是什么意思? 其实我是不希望在路径是 出现那个  Web   的。 ###### 永久性的重定向 更深入了解看看这个 http://nginx.org/en/docs/http/converting_rewrite_rules.html
    2020-05-29 17:31:19
    赞同 展开评论