reverse_proxy:nginx_reverse_proxy:passing_request_headers
Differences
This shows you the differences between two versions of the page.
reverse_proxy:nginx_reverse_proxy:passing_request_headers [2025/05/20 16:14] – created peter | reverse_proxy:nginx_reverse_proxy:passing_request_headers [2025/05/20 16:18] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Reverse Proxy - NGINX Reverse Proxy - Passing Request Headers ====== | ====== Reverse Proxy - NGINX Reverse Proxy - Passing Request Headers ====== | ||
+ | |||
+ | By default, NGINX modifies two header fields in proxied requests, “Host” and “Connection”, | ||
+ | |||
+ | * “Host” is set to the value of the **$proxy_host** variable, and | ||
+ | * “Connection” is set to close. | ||
+ | |||
+ | To change these settings, as well as modify other header fields, use the **proxy_set_header** directive. | ||
+ | |||
+ | * This directive can be specified in a location or higher. | ||
+ | * It can also be specified in a particular server context or in the http block. | ||
+ | |||
+ | For example: | ||
+ | |||
+ | < | ||
+ | location /some/path/ { | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_set_header X-Real-IP $remote_addr; | ||
+ | proxy_pass http:// | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== To prevent a header field from being passed to the proxied server ===== | ||
+ | |||
+ | Set it to an empty string as follows: | ||
+ | |||
+ | < | ||
+ | location /some/path/ { | ||
+ | proxy_set_header Accept-Encoding ""; | ||
+ | proxy_pass http:// | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ---- | ||
reverse_proxy/nginx_reverse_proxy/passing_request_headers.txt · Last modified: 2025/05/20 16:18 by peter