[英]NGINX proxy_pass based on custom header
I am setting up a reverse proxy on Nginx, and the client request has a header X-OUTBOUND-URI
, which will then hit my reverse proxy on a particular port.我正在 Nginx 上设置反向代理,并且客户端请求具有标头
X-OUTBOUND-URI
,然后它将在特定端口上访问我的反向代理。
I am trying to do a proxy_pass on the variable $http_x_outbound_uri
, but there is a resolver error.我正在尝试对变量
$http_x_outbound_uri
执行 proxy_pass ,但存在解析器错误。
server {
listen 8082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass $http_x_outbound_uri;
}
}
This is the curl command that is used: curl localhost:8082 -H "X-OUTBOUND-URI: http://localhost:9001"
, and I have a webserver running on port 9001.这是使用的 curl 命令:
curl localhost:8082 -H "X-OUTBOUND-URI: http://localhost:9001"
,我有一个在端口 9001 上运行的网络服务器。
Am I doing this wrongly?我做错了吗? Also, for this use case, is it more suitable to do a redirect instead.
此外,对于这个用例,是否更适合进行重定向。 Thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.