【发布时间】:2021-11-04 19:59:11
【问题描述】:
所以我有一个 NGNIX 服务器,它从同一位置 (Akamai) 接收流量,并根据传入 URL 的路径将流量发送到不同的应用程序。
我已向 Akamai 添加了一个新来源,这意味着一些传入请求现在有了新路径。问题是我的应用程序需要路径是某个值。
由于我与其他来源共享 Akamai 插槽,因此我无法将具有相同路径的请求发送到两个不同的来源,因为插槽对将流量引导至哪个源服务器感到困惑。
所以我想做的是在将路径传递给应用程序之前更改路径。 我不确定执行此操作的最佳方法,需要一些帮助。 我应该使用 rewrite、redirect 还是 sub_filter?
我实际上已经尝试了所有这三种方法,但在这个非常简单的任务中我遗漏了一些东西。
location /incoming_path {
max_ranges 0;
proxy_set_header Accept-Encoding "";
proxy_pass https://\$upstream_application:9002;
proxy_ssl_server_name on;
proxy_ssl_certificate /etc/nginx/conf.d/server_cert.pem;
proxy_ssl_certificate_key /etc/nginx/conf.d/server_key.pem;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$proxy_protocol_addr;
sub_filter_types *;
sub_filter "https://\$proxy_host/incoming_path" "https://\$host/new_path"
sub_filter_once on;
}
非常感谢任何关于如何实现这一目标的想法/想法,在此先感谢。
【问题讨论】:
标签: nginx nginx-reverse-proxy nginx-config nginx-location