加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

如何通过nginx反向代理特定的URL?

发布时间:2020-05-27 11:55:25 所属栏目:Nginx 来源:互联网
导读:我有一个运行在http:// localhost:8080的服务器,我希望该服务器的特定url由nginx代理.例如,我只希望将http:// localhost:8080 / test /(.*)反向代理到http:// localhost / test /(.*).我正在将另一台服务器传播到http:// localhost /.最佳答案那只是一

我有一个运行在http:// localhost:8080的服务器,我希望该服务器的特定url由nginx代理.

例如,我只希望将http:// localhost:8080 / test /(.*)反向代理到http:// localhost / test /(.*).

我正在将另一台服务器传播到http:// localhost /.

最佳答案 那只是一个简单的位置块呢?

server {
    # ... other stuff

    location /test/ {
        try_files $uri @testproxy;
    }

    location @testproxy {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        # all your params
    }
}

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读