URL的nginx位置proxy_pass

问题描述 投票:0回答:1

在我的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?

谢谢

nginx nginx-location nginx-reverse-proxy nginx-config
1个回答
0
投票

尝试一下:

location /*-service/ { // your stuff goes here }

或者,如果您有服务名称列表

location /(user|auth)-service/ { // your stuff goes here }
© www.soinside.com 2019 - 2024. All rights reserved.