nginx 配置反向代理根目录到其他服务器

 

location /detail/json {
if ( $uri = "/detail/json" ) {
rewrite "/detail/json" /index.html break;
}
alias /data/web/static_test/detail/json/$host/;
proxy_pass http://192.168.1.2;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
index index.html;
default_type application/json;
proxy_redirect off;
proxy_intercept_errors on;
error_page 403 404 = @index;

location /lvpai/ware {
proxy_pass http://192.1.1.2:9997;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location @index {
try_files $uri /lvpai/ware/$uri;
}

解读:在1.1上面配置nginx 把根路径配置在1.2上面

如果访问的地址是http://域名/detail/json/xx  实际上获取的资源是1.2相应的路径下的资源

如果1.2下不存在要访问的资源,然后去找try_files

 

posted @ 2019-05-27 19:01  ivy_wang  阅读(2709)  评论(0编辑  收藏  举报