September 13, 2012 03:32AM
On Sep 13, 2012, at 1:04 , thigomes wrote:

> Just to complete the information, in my case I have two configuration
> according with the web server, so:
>
> # TO VARNISH
> location / {
> proxy_redirect off; # Do not redirect this proxy - It needs to be
> pass-through
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Server-Address $server_addr;
> proxy_connect_timeout 5s;
> proxy_read_timeout 300s;
> proxy_pass_header Set-Cookie;
> proxy_pass http://localhost:6081; # Pass all traffic through to Varnish
> }
>
> TO APACHE
> location / {
> client_max_body_size 10m;
> client_body_buffer_size 128k;
> proxy_send_timeout 90;
> proxy_read_timeout 90;
> proxy_buffer_size 32k;
> proxy_buffers 8 16k;
> proxy_busy_buffers_size 64k;
> proxy_temp_file_write_size 64k;
> proxy_connect_timeout 30s;
> proxy_redirect http://domain.com:8081 http://domain.com;
> proxy_redirect http://www.domain.com:8081 http://www.domain.com;
>
> proxy_pass http://192.168.1.7:8081/;
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> }
>
> In the case varnish server not response, the request will forward to apache
> server.

Backup servers are not supported with ip_hash upstream.
You should use something like this:

upstream backend {
server 192.168.1.5:6081; # varnish server
server 192.168.1.7:80 backup; # apache server
}

server {
location / {
proxy_pass http://backend;
...
}
}

However, you can omit varnish at all and use nginx built-in cache:

proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=CACHE:10m;

server {
location / {
proxy_pass http://192.168.1.7;
proxy_cache CACHE;
...
}
}


--
Igor Sysoev
http://nginx.com/support.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Condition in upstream

thigomes September 12, 2012 04:31PM

Re: Condition in upstream

thigomes September 12, 2012 05:04PM

Re: Condition in upstream

Igor Sysoev September 13, 2012 03:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 163
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