如何通过 nginx 反向代理特定的 url? [英] how to reverse proxy via nginx a specific url?
本文介绍了如何通过 nginx 反向代理特定的 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一台运行在 http://localhost:8080
上的服务器,我希望该服务器的特定 url 由 nginx 代理.
I have a server running at http://localhost:8080
i want a specific url of this server to be proxied by nginx.
例如,我只希望 http://localhost:8080/test/(.*)
被反向代理到 http://localhost/test/(.*)
.
For example, i only want http://localhost:8080/test/(.*)
to be reverse proxied to http://localhost/test/(.*)
.
我正在将另一台服务器代理到 http://localhost/
.
I'm proxing another server to http://localhost/
.
推荐答案
我以某种方式做到了,并且奏效了.无论如何,感谢您的评论.:)
I made it somehow this way and it worked. Thanks for your comment anyway. :)
server {
listen 80;
# ... other stuff
upstream backend1 {
server 127.0.0.1:8080;
}
location /test/ {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://backend1/test/;
}
}
这篇关于如何通过 nginx 反向代理特定的 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文