Proxy_pass remote nginx server

hussan nginx-forum at nginx.us
Tue Dec 17 17:18:00 UTC 2013


Hi,

i have 2 nginx server, one with my main site(www.site.com) and other nginx
server with my blog(www.site2.com).

My nginx server 1 have this configurarion: on location /blog/ i have a
(proxy_pass) to blog on nginx server 2

*==========
server {
  server_name www.site.com;
  root "/home/site/site.com";

  index index.php;
  client_max_body_size 10m;

	access_log /home/site/_logs/access.log;
	error_log /home/site/_logs/error.log;

	location /blog/ {
	        proxy_pass http://www.site2.com/;
	}
	location / {
	          try_files $uri $uri/ /index.php$uri?$args;
	}
	location ~ "^(.+\.php)($|/)" {
	        fastcgi_split_path_info ^(.+\.php)(.*)$;

	        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
	        fastcgi_param PATH_INFO $fastcgi_path_info;
	        fastcgi_param SERVER_NAME $host;
	        fastcgi_read_timeout 120;
	        fastcgi_pass   unix:/var/run/site_fpm.sock;
	        include        fastcgi_params;
	}
	#       location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
	#                       expires max;
	#               #       log_not_found off;
	#                       access_log off;
	#       }

	#       location ~* \.(html|htm)$ {
	#               expires 30m;
	#       }

	location ~* /\.(ht|git|svn) {
	        deny  all;
	}
}
*==========

Nginx server 2 (blog) config

*==========

server {
  server_name www.site2.com;
  root "/home/site2/www.site2.com";



  index index.php;
  client_max_body_size 10m;

        access_log /home/site2/_logs/access.log;
        error_log /home/site2/_logs/error.log;



        location / {
                        try_files $uri $uri/ /index.php$uri?$args;
        }


             location ~ "^(.+\.php)($|/)" {
                fastcgi_split_path_info ^(.+\.php)(.*)$;

                fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
                fastcgi_param SCRIPT_NAME $fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_param SERVER_NAME $host;
                fastcgi_read_timeout 120;
            fastcgi_pass   unix:/var/run/site2_fpm.sock;
                include        fastcgi_params;
    }


        location ~* /\.(ht|git|svn) {
                deny  all;
        }
}


*==========

When i try www.site.com/blog/ proxy_pass works, go to nginx server 2 , and
my css/js are loaded fine. But when try www.site.com/blog/wp-admin/ is
redirected to www.site.com/blog/wp-login.php (on server 1) 404 error(i dont
have this file in server 1). 

how i can solve this? all www.site.com/blog/* trafic go to proxy_pass on
nginx server 2 www.site2.com/* ?

thanls

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,245606,245606#msg-245606



More information about the nginx mailing list