前端之家收集整理的这篇文章主要介绍了
如何通过nginx反向代理特定的URL? ,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个运行在http:// localhost:8080的服务器,我希望该服务器的特定url由Nginx代理.@H_502_2@
例如,我只希望将http:// localhost:8080 / test /(.*)反向代理到http:// localhost / test /(.*).@H_502_2@
我正在将另一台服务器传播到http:// localhost /.@H_502_2@
最佳答案
那只是一个简单的位置块呢?@H_
502_2@
@H_502_2@
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
}
}