Welcome! Log In Create A New Profile

Advanced

Re: Possible to normalize headers in nginx?

August 08, 2009 03:00AM
On Sat, Aug 08, 2009 at 05:28:36AM +0200, Victor Iggy wrote:

> 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 'if ($request_uri ~ "\.(jpeg|jpg|...|mkv)")' should be rewritten as

location ~ \.(jpeg|jpg|...|mkv)$ {
proxy_pass http://72.11.142.91:7999;
proxy_set_header Accept-Encoding "";
...
}

The whole configuration may be

server {


if ($http_accept_encoding ~ deflate) {
set $encoding "deflate";
break;
}

if ($http_accept_encoding ~ gzip) {
set $encoding "gzip";
break;
}

location / {
proxy_pass http://72.11.142.91:7999;
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;
proxy_set_header Accept-Encoding $encoding;
}

location ~ \.(jpeg|jpg|...|mkv)$ {
proxy_pass http://72.11.142.91:7999;
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;
proxy_set_header Accept-Encoding "";
}
}

--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Possible to normalize headers in nginx?

Victor Iggy August 07, 2009 10:01PM

Re: Possible to normalize headers in nginx?

Victor Iggy August 07, 2009 11:28PM

Re: Possible to normalize headers in nginx?

Igor Sysoev August 08, 2009 03:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 316
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready