nginx proxy pass redirects ignore port 获取客户端IP、端口号
实践:
1、
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
cat nginx.conf
http {
include mime.types;
#include luawaf.conf;
include proxy.conf;
cat proxy.conf
proxy_set_header X-Real-IP $remote_addr; 客户端IP
proxy_set_header X-Real-PORT $remote_port; 客户端端口
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
nginx proxy pass redirects ignore port
$host
in this order of precedence: host name from the request line, or host name from the “Host” request header field, or the server name matching a request
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header
proxy_set_header Host $host:$proxy_port;
NGINX Docs | NGINX Reverse Proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/#passing-request-headers