Welcome! Log In Create A New Profile

Advanced

Re: upstream: ip_hash and backup

August 11, 2014 06:15AM
Hello,
i have this little solution of load balancer at the front end using nginx and two php-fpm application servers at the backend and i installed php-fpm on the load balancer as a backup application server, i wanted to use ip_hash with backup i tried your solution but it keep giving me 502 bad gateway errors.
this is my configuration
upstream apps {
ip_hash;
server 10.128.149.234:9000;
server 10.128.151.32:9000;
}
upstream backup {
server unix:/var/run/php5-fpm.sock;
}



server {

listen 80 default_server;
index index.php;
root /var/www/wp;
server_name .example.com;
set $mreq 1;
if ( $request_method = POST ){
set $mreq 0;
}
if ( $uri ~ "/wp-" ) {
set $mreq 0;
}
if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_|wordpre
ss_logged_in_" ) {
set $mreq 0;
}

location / {

default_type text/html;
fastcgi_index index.php;
include fastcgi_params;
index index.php;
if ( $mreq = 1){
add_header uri $request_uri;
set $memcached_key data-$scheme://$host$request_uri;
memcached_pass 104.131.208.224:11211;
error_page 404 500 502 = @fallback;
}

if ( $uri ~ \.php$ ) {
fastcgi_pass apps;
error_page 502 504 = @fallbackbackup;
}
}
location @fallback {

if ( $uri ~ \.php$ ) {
fastcgi_pass apps;
error_page 502 504 = @fallbackbackup;

}
}
location @fallbackbackup {
fastcgi_pass backup;
}
}
Subject Author Posted

upstream: ip_hash and backup

John Moore June 30, 2011 02:36PM

Re: upstream: ip_hash and backup

Maxim Dounin June 30, 2011 02:50PM

Re: upstream: ip_hash and backup

John Moore June 30, 2011 03:58PM

Re: upstream: ip_hash and backup

Maxim Dounin July 01, 2011 01:54AM

Re: upstream: ip_hash and backup

husseingalal August 11, 2014 06:15AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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