频道
bg

Nginx proxy_pass

coding二月 14, 20161mins
Nginx OP

Proxy PassH2

Nginx使用proxy_pass来转发请求

nginx

location /some/path/ {
proxy_pass http://www.example.com/link/;
}
location ~ \.php {
proxy_pass http://127.0.0.1:8000;
}

需要注意的是,地址后面(http://www.example.com)是否跟随URI是不一样的,()

  • 如果有路径,匹配location 的部分会被URI替换掉
  • 如果没有路径,则location 的部分不会被替换掉,整个路径都会被转发

Note that in the first example above, the address of the proxied server is followed by a URI, /link/. If the URI is specified along with the address, it replaces the part of the request URI that matches the location parameter. For example, here the request with the /some/path/page.html URI will be proxied to http://www.example.com/link/page.html. If the address is specified without a URI, or it is not possible to determine the part of URI to be replaced, the full request URI is passed (possibly, modified).

评论


新的评论

匹配您的Gravatar头像

Joen Yu

@2022 JoenYu, all rights reserved. Made with love.