nginx.conf里面的有一个配置是这样的
location / {
default_type 'application/json;charset=utf-8';
# here must be use rewrite_by_lua instead of content_by_lua
rewrite_by_lua '
# 一些url的处理
'
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.1.101:8012/;
}
其中,rewrite_by_lua里面根据url的规则,做了下rewrite操作
现在想增加一个web站点的location, 如下
location = ~^/admin {
root html;
index index.html index.htm;
}
通常情况下,如果没有上面的rewrite的location, 根loation /会指向下面的这个html页面
但是我本以为这个/admin的location会生效。 毕竟location是遵循惰性加载的。实际上并没有生效。
不知道为啥?
location = ~^/admin
是什么语法?要么精确匹配,要么正则匹配,哪有一起用的?我猜你应该是想用location /admin
。文档: https://nginx.org/en/docs/htt...