Welcome! Log In Create A New Profile

Advanced

Proxy_pass remote nginx server

December 17, 2013 12:18PM
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
Subject Author Posted

Proxy_pass remote nginx server

hussan December 17, 2013 12:18PM

Re: Proxy_pass remote nginx server

Francis Daly December 18, 2013 08:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready