nginx - URL的nginx位置proxy_pass
问题描述
在我的 nginx 配置中,我想代理传递以下 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 }
推荐阅读
- c# - c# DataAnnotations 如何验证 IList 中的电话号码
? - swift - 输入我的卡详细信息后,我无法获得 Stripe 付款 ID
- c++ - C++ 是否有库社区?
- ios - 如何解决“请求的应用程序不可用或不存在”。在试飞中
- excel - 正确总结双日班的日历天数 - Excel
- ssl - GeoServer 和 MariaDB 之间的连接问题
- json - 部署 ARM 模板时要更改的 JSON 参数
- recaptcha - 为什么 reCAPTCHA 允许垃圾邮件?
- python - 优先加入 PySpark 数据帧
- php - wkhtml用utf-8泰米尔语导出pdf