简体   繁体   English

如何使用Nginx反向代理首页/根目录?

[英]How do I reverse proxy the homepage/root using nginx?

I'm interested in sending folks who go to the root/homepage of my site to another server. 我有兴趣将访问我网站根目录/首页的人员发送到另一台服务器。

If they go anywhere else (/news or /contact or /hi.html or any of the dozens of other pages) they get proxied to a different server. 如果它们转到其他任何地方(/ news或/ contact或/hi.html或其他数十个页面),则它们将被代理到其他服务器。

Since "/" is the nginx catchall to send anything that's not defined to a particular server, and since "/" also represents the homepage, you can see my predicament. 由于“ /”是nginx的包罗万象,可以将任何未定义的内容发送到特定服务器,并且由于“ /”也代表主页,因此您可以看到我的困境。

Essentially the root/homepage is its own server. 本质上,根目录/主页是其自己的服务器。 Everything else is on a different server. 其他所有内容都在其他服务器上。

Thoughts? 有什么想法吗?

location =/ {
    # only "/" requests
}

location / {
    # everything else
}

More information: http://nginx.org/en/docs/http/ngx_http_core_module.html#location 详细信息: http : //nginx.org/en/docs/http/ngx_http_core_module.html#location

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM