URL的nginx位置proxy_pass

时间:2020-02-25 09:47:21

标签: nginx nginx-location nginx-reverse-proxy nginx-config

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

谢谢

1 个答案:

答案 0 :(得分:0)

尝试一下:

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

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

location /(user|auth)-service/ { // your stuff goes here }