在我的nginx配置中,我要proxy_pass以下URL
原始网址:
http://1.1.1.1:8080/SOME-SERVICE/sub-path
代理路径:
http://2.2.2.2:1234/SOME-SERVICE/sub-path
SOME-SERVICE值将具有不同的值,例如:
http://1.1.1.1:8080/user-service/sub-path
http://1.1.1.1:8080/auth-service/sub-path
我应该如何编写位置路径模式以匹配通用SOME-SERVICE值并使用该值代理URL?
谢谢
尝试一下:
location /*-service/ { // your stuff goes here }
或者,如果您有服务名称列表
location /(user|auth)-service/ { // your stuff goes here }