Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
937 views
in Technique[技术] by (71.8m points)

nginx location 优先级错误了, 怎么解决

  1. 这是我的2个location

image

  1. 当我访问的时候

http://localhost:8080/fad-ssp/api/ad-pos-service/adposinfo/admin/list/?current=1&size=10
发现是请求并没有匹配到.
image

  1. 然后我去查看rewrite 的实际路径, 结果发现是/api/ 匹配到了, 实在是百思不得原因.(如果将上面的两个location 互换位置,会发现, 所有的请求 /api/ 都匹配到 /fad-ssp/ 里面的location里面去了, 这个时候会造成404. )

image
请教大家一下, 我要如何隔离这两种location


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

location ~ /abc是对URI正则表达式匹配,这意味着任何含有/abc的URI 都会匹配,你可能需要用:location ~ ^/abc来代替。这会匹配以/abc开头的所有URI。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...