header with underscore

Igor Sysoev igor at sysoev.ru
Thu Jan 27 13:15:14 MSK 2011


On Thu, Jan 27, 2011 at 09:41:39AM +0100, Daniele Melosi wrote:

> Hi all,
> 
> when proxy from nginx, if the headers contains underscore it won't be
> passed:
> $ curl -s http://proxy01.ced:8888/check_headers.php --header "Host:
> myhost" --header "X_UP_CALLING_LINE_ID: daniele" | grep daniele
> 
> $ curl -s http://proxy01.ced:8888/check_headers.php --header "Host:
> myhost" --header "X-UP-CALLING-LINE-ID: daniele" | grep daniele
>     [HTTP_X_UP_CALLING_LINE_ID] => daniele
> 
> 
> This is my configuration:
> server {
>                 listen          8888;
>                 server_name proxy01.ced;
> 
>                 keepalive_timeout 0;
>                 ssi off;
> 
>                 underscores_in_headers on;
> 
>                 location ~ / {
>                         proxy_pass        http://test01.ced$request_uri;
>                         proxy_set_header  X-Real-IP  $remote_addr;
>                         proxy_set_header  Host $host;
>                         proxy_set_header  X-Org-host $host;
>                         proxy_set_header  X-Org-uri $request_uri;
>                         proxy_set_header  X-Forwarded-For
> $proxy_add_x_forwarded_for;
>                         proxy_pass_header Server;
>                         proxy_set_header X-UP-CALLING-LINE-ID
> $HTTP_X_UP_CALLING_LINE_ID;
>                 }
> }
> 
> I tried to play with:
> - underscores_in_headers on|off
> - proxy_set_header X-UP-CALLING-LINE-ID $HTTP_X_UP_CALLING_LINE_ID
> - proxy_pass_header X-UP-CALLING-LINE-ID (also with underscore)
> 
> lines but without any fortune :)

You should set
     underscores_in_headers  on;

and remove
     proxy_pass_header  X-UP-CALLING-LINE-ID 
     proxy_set_header   X-UP-CALLING-LINE-ID  ...

nginx should pass "X_UP_CALLING_LINE_ID: daniele" to backend as is.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list