我现在想配置 nginx 实现以下需求:
1 、主页通过 nginx 直接访问一个静态页面,静态页面目录是:/www/main/index.html
2 、其他服务接口通过 nginx 代理,转发给后端的 python 服务,端口是 20002
我现在的想法是通过两个 location 配置实现,但是在折腾了半天,也没有折腾出来,求各位前辈、高手给指点指点
append:
location = / {
root /www/main;
index index.html;
}
location / {
proxy_pass http://xx.xx.xx.xx:20002;
}
我现在这种写法一直不能实现,我对这种写法的理解是,当我访问首页www.xxx.com的时候,nginx通过精确匹配,找到第一个location,
当我访问www.xxx.com/xxx的时候,nginx找到第二个location,
但是这样配置的话,首页无法访问
1 、主页通过 nginx 直接访问一个静态页面,静态页面目录是:/www/main/index.html
2 、其他服务接口通过 nginx 代理,转发给后端的 python 服务,端口是 20002
我现在的想法是通过两个 location 配置实现,但是在折腾了半天,也没有折腾出来,求各位前辈、高手给指点指点
append:
location = / {
root /www/main;
index index.html;
}
location / {
proxy_pass http://xx.xx.xx.xx:20002;
}
我现在这种写法一直不能实现,我对这种写法的理解是,当我访问首页www.xxx.com的时候,nginx通过精确匹配,找到第一个location,
当我访问www.xxx.com/xxx的时候,nginx找到第二个location,
但是这样配置的话,首页无法访问