Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide a client request header with a Nginx reverse proxy server

Tags:

I have a Nginx websocket reverse proxy and I would like to hide a HTTP header from the client request.

proxy_hide_header hides the server response headers and can't be used for hiding client request headers.

I would like to do that because the websocket server behind nginx doesn't work well with the websocket extension "permessage-deflate" so I would like to remove the Sec-WebSocket-Extensions header from client requests.

like image 430
e741af0d41bc74bf854041f1fbdbf Avatar asked Apr 15 '15 08:04

e741af0d41bc74bf854041f1fbdbf


People also ask

Does nginx pass headers?

By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client.

What is proxy_pass in nginx?

The proxy_pass setting makes the Nginx reverse proxy setup work. The proxy_pass is configured in the location section of any virtual host configuration file. To set up an Nginx proxy_pass globally, edit the default file in Nginx's sites-available folder.

Can Nginx be used as reverse proxy?

Nginx is an open source web server that can also serve as a reverse proxy. Apart from being used to host websites, it's also one of the most widely used reverse proxy and load balancing solutions.

What is Proxy_set_header Nginx?

To adjust or set headers for proxied connections, use the proxy_set_header directive, followed by the header value. You can find a list of all available Request Headers and their allowed values here . If you want to prevent a header from being passed to the proxied server, set it to an empty string "" .


1 Answers

You can set a header value to void and Nginx will drop it :

proxy_set_header       Sec-WebSocket-Extensions "";
like image 102
Eric Ly Avatar answered Sep 22 '22 16:09

Eric Ly