Possible to normalize headers in nginx?

I have the following set to normalize Accept-Encoding headers for squid
which sits down stream.

However, I am getting an issue with the following error…

[emerg]: “proxy_set_header” directive is not allowed here in
/opt/extra/nginx/conf/nginx-master.conf:51
configuration file /opt/extra/nginx/conf/nginx-master.conf test failed

Am I out of luck when it comes to normalizing http headers with nginx?

server {
    listen       3000;
    server_name  localhost;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For

$proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

        if ($http_accept_encoding ~ deflate) {
            proxy_set_header Accept-Encoding deflate;
        }
        if ($http_accept_encoding ~ gzip) {
            proxy_set_header Accept-Encoding gzip;
        }
        if ($request_uri ~

“.(jpeg|jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|ico|swf|mp4|flv|mov|dmg|mkv)”)
{
proxy_set_header Accept-Encoding “”;
}

        proxy_pass http://72.11.142.91:7999/;
        break;
    }
}

I actually figured out my answer… the configuration is a bit weird but
it works…

is the answer… for anyone who cares.

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For 

$proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

        if ($http_accept_encoding ~ deflate) {
            set $normal_encoding "deflate";
            proxy_pass http://72.11.142.91:7999;
            break;
        }
        if ($http_accept_encoding ~ gzip) {
            set $normal_encoding "gzip";
            proxy_pass http://72.11.142.91:7999;
            break;
        }
        if ($request_uri ~ 

“.(jpeg|jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|ico|swf|mp4|flv|mov|dmg|mkv)”)
{
set $normal_encoding “”;
proxy_pass http://72.11.142.91:7999;
break;
}
proxy_set_header Accept-Encoding $normal_encoding;

    }

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs