# Proxy\_pass remote nginx server

**URL:** <https://www.ruby-forum.com/t/proxy-pass-remote-nginx-server/238108>\
**Category:** NGINX\
**Created:** [December 17, 2013, 6:18pm UTC](https://www.ruby-forum.com/t/proxy-pass-remote-nginx-server/238108 "2013-12-17T18:18:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [December 17, 2013, 6:18pm UTC](https://www.ruby-forum.com/t/proxy-pass-remote-nginx-server/238108/1 "2013-12-17T18:18:49Z")

</div>

Hi,

i have 2 nginx server, one with my main site([www.site.com](http://www.site.com)) and other  
nginx  
server with my blog([www.site2.com](http://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](http://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/](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](http://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 [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/blog/) proxy\_pass works, go to nginx server 2 ,  
and  
my css/js are loaded fine. But when try [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/blog/wp-admin/) is  
redirected to [Custom Application Development Software for Business - Salesforce.com](http://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 [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/blog/*) trafic go to proxy\_pass on  
nginx server 2 [www.site2.com/\*](http://www.site2.com/*) ?

thanls

Posted at Nginx Forum:

> **[Proxy\_pass remote nginx server](https://forum.nginx.org/read.php?2,245606,245606#msg-245606)**
>
> 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 {

---

<div class="post-metadata">

**Author:** ![hussan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/7ea924/32.png) [@hussan](https://www.ruby-forum.com/u/hussan)\
**Post date:** [December 17, 2013, 9:35pm UTC](https://www.ruby-forum.com/t/proxy-pass-remote-nginx-server/238108/2 "2013-12-17T21:35:45Z")

</div>

On Tue, Dec 17, 2013 at 12:18:00PM -0500, hussan wrote:

Hi there,

> location /blog/ {  
> location / {  
> location ~ “^(.+.php)($|/)” {  
> location ~\* /.(ht|git|svn) {

> When i try [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/blog/) proxy\_pass works, go to nginx server 2 , and  
> my css/js are loaded fine. But when try [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/blog/wp-admin/) is  
> redirected to [Custom Application Development Software for Business - Salesforce.com](http://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 [Custom Application Development Software for Business - Salesforce.com](http://www.site.com/blog/*) trafic go to proxy\_pass on  
> nginx server 2 [www.site2.com/\*](http://www.site2.com/*) ?

[http://nginx.org/r/location](http://nginx.org/r/location)

You want ^~

## f

Francis D. removed\_email\_address@domain.invalid
