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

 

转载于:https://www.cnblogs.com/guniang/p/10932447.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值