为了账号安全,请及时绑定邮箱和手机立即绑定

Nginx 反向代理整站与指定目录问题

Nginx 反向代理整站与指定目录问题

慕工程0101907 2019-05-23 19:13:53
现在部署了一个web,本机地址是localhost:6666/blogs/user然后利用nginx反代配置如下:upstreammyweb{serverlocalhost:6666;}server{listen80;server_namemyhost.net;indexindex.phpindex.htmlindex.htmdefault.phpdefault.htmdefault.html;root/www/wwwroot/host.net;location/{proxy_passhttp://localhost:6666/blogs/user/;proxy_set_headerHost$host:$server_port;proxy_set_headerX-Real-IP$remote_addr;client_max_body_size10m;}这样配置后可以访问,然而又发现一个问题是这个web还有一个路由是localhost:6666/admin我按照搜出来的方法又加了一个配置如下:location^~/admin/{proxy_passhttp://localhost:6666/admin/;proxy_set_headerHost$host:$server_port;proxy_set_headerX-Real-IP$remote_addr;client_max_body_size10m;}但是似乎没有用........不知道何解各位还请帮忙看看谢谢!
查看完整描述

2 回答

?
弑天下

TA贡献1818条经验 获得超8个赞

使用try_files$uri$uri//;
location/{
proxy_passhttp://localhost:6666;
proxy_set_headerHost$host:$server_port;
proxy_set_headerX-Real-IP$remote_addr;
client_max_body_size10m;
try_files$uri$uri//;
}
                            
查看完整回答
反对 回复 2019-05-23
?
烙印99

TA贡献1829条经验 获得超13个赞

试试去掉后面的proxy_pass后面的/admin/
location^~/admin/{
proxy_passhttp://localhost:6666;
proxy_set_headerHost$host:$server_port;
proxy_set_headerX-Real-IP$remote_addr;
client_max_body_size10m;
}
                            
查看完整回答
反对 回复 2019-05-23
  • 2 回答
  • 0 关注
  • 1966 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号