Nginx 的 proxy_pass 简单使用记录

nginx代理配置(proxy_pass)的四种情况:

访问url:http://127.0.0.1/test/index.html

情况一

location /test/ {
    proxy_pass http://127.0.0.1:8080;
}

最终地址为:http://127.0.0.1:8080/test/index.html

情况二

location /test/ {
    proxy_pass http://127.0.0.1:8080/;
}

最终地址为:http://127.0.0.1:8080/index.html

情况三

location /test/ {
    proxy_pass http://127.0.0.1:8080/api;
}

最终地址为:http://127.0.0.1:8080/apiindex.html

情况四

location /test/ {
    proxy_pass http://127.0.0.1:8080/api/;
}

最终地址为:http://127.0.0.1:8080/api/index.html


相关文章:
nginx的location和proxy_pass

为者常成,行者常至