# Static Content on Different Server Isn't Loaded?

**URL:** <https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406>\
**Category:** NGINX\
**Created:** [June 22, 2015, 2:35pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406 "2015-06-22T14:35:54Z")\
**Posts on this page:** 14\
**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:** [June 22, 2015, 2:35pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/1 "2015-06-22T14:35:54Z")

</div>

Hi Team,

I have static content available on the remote server (say NODE 02) and  
PATH:  
…/livetest/WEB-INF/static/classes/  
under which I have /image, /js, /styles folders

I have installed nginx-1.8.0 on server (Say Node 01).

While accessing the application, the static contents are not getting  
loaded.

Pls. suggest?

I tried below option:

```
    location ~*\.(js|jpg|png|css)$ {
        root /WEB-INF/classes/static/;
        http://<DNS_NODE_02>/livetest/WEB-INF/classes/static/classes;
        expires 30d;
    }

```

The resultant in access.log shows that the path is weird

/var/gvp/Nginx/nginx-1.8.0/http://\<DNS\_NODE\_02\>/livetest/WEB-INF/classes/static/classes/livetest/…

Best regards,  
Maddy

Posted at Nginx Forum:

> **[Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,259786#msg-259786)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [June 23, 2015, 11:49pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/2 "2015-06-23T23:49:12Z")

</div>

On Mon, Jun 22, 2015 at 08:35:32AM -0400, smsmaddy1981 wrote:

Hi there,

> I have static content available on the remote server (say NODE 02) and PATH:  
> ../livetest/WEB-INF/static/classes/  
> under which I have /image, /js, /styles folders

nginx doesn’t know about static content.

nginx knows about requests that should be served from this  
filesystem – directives root ([Module ngx\_http\_core\_module](http://nginx.org/r/root)) or alias  
([Module ngx\_http\_core\_module](http://nginx.org/r/alias)) are probably most interesting –  
and requests that should be proxy\_pass’ed to another web server  
([Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_pass)) and requests that should be  
fastcgi\_pass’ed to a fastcgi server ([Module ngx\_http\_fastcgi\_module](http://nginx.org/r/fastcgi_pass))  
and a few other things.

> While accessing the application, the static contents are not getting  
> loaded.

Can you show one request for one thing that you consider to be some  
static  
content? “curl” is usually a good command for showing the request made  
and the response received.

What do you want nginx to do with this request?

The answer should (probably) be “serve _this named file_ from the local  
filesystem”, or “tell the client to go and request _this other url_  
from this or another web server”, or “fetch _this specific url_ from  
_this other web server_, and send it to the client”.

> ```
> location ~*\.(js|jpg|png|css)$ {
> root /WEB-INF/classes/static/;
> http://<DNS_NODE_02>/livetest/WEB-INF/classes/static/classes;
> expires 30d;
> }
> 
> ```

I get

nginx: [emerg] unknown directive  
“http://\<DNS\_NODE\_02\>/livetest/WEB-INF/classes/static/classes” in  
/usr/local/nginx/conf/nginx.conf:15

If you are going to show config you use, please copy-paste and do not  
re-type.

After you describe what exactly you want nginx to do, if the answer is  
not already clear to you, possibly someone will be able to help.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 2, 2015, 1:33am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/3 "2015-08-02T01:33:32Z")

</div>

Hi Francis,

I tried possible options suggested proxy\_pass, fastcgi\_pass…and was  
unsuccessful  
This query was posted in another request  
[Re: remote server static content is not getting loaded](http://forum.nginx.org/read.php?2,260231,260232#msg-260232) and you are  
smart  
to redirect me back to this earlier request.

I would like to detail more on my question pls.,  
I have plenty of 5 different services deployed on different 5 servers. I  
have NGINX deployed on one server (1) where application 1 is deployed.  
Other  
services are on different servers (2,3,4,5).

Now, whenever there is an web request…via NGINX… the configuration  
is  
able to read the static data of service 1…as it is deployed on the  
same  
server where NGINX is installed.

Issue arises, when trying to access services deployed on other servers  
(2,3,4,5). request is reached via upstream servers configured.  
Unfortunately, the static content (2,3,4,5) servers are not getting  
fetched/loaded. Rather, it is trying to find the data on NGINX installed  
machine only.

error.log:  
2015/08/02 01:11:09 [error] 30243#0: \*72 open()  
“/var/gvp/Nginx/nginx-1.8.0/html/pvp/img/rvi.jpg” failed (2: No such  
file or  
directory)

nginx.conf details below

server {  
listen 80;  
server\_name ser-01;

```
   location /pvp/{
      proxy_pass http://ser02;
   }

   location /gen/ {
      proxy_pass http://ser03;
   }

   location /config/ {
      proxy_pass http://ser04;
   }

   location /stat/ {
      proxy_pass http://ser05;
   }

```

}

```
upstream ser01{
    ip_hash;
    server 10.177.54.92:9092;
    server 10.177.54.93:9092;
}

upstream ser02 {
    ip_hash;
    server 10.176.54.92:9091;
    server 10.176.54.93:9091;
}

upstream ser03 {
    ip_hash;
    server 10.175.54.94:8181;
    server 10.175.54.95:8181;
}

upstream ser04 {
    ip_hash;
    server 10.174.54.74:8080;
    server 10.174.54.76:8080;
}

```

Now, please assist me with an pointing to an code snippet/examples which  
show server my above requirement.

Your answer will decide my consideration of Nginx implementation in my  
project. Awaiting for your updates.

Best regards,  
Maddy

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,260695#msg-260695)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 2, 2015, 11:44pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/4 "2015-08-02T23:44:57Z")

</div>

Hi Francis,

Yes, the file/s are located. Verified with all servers.

Best regards,  
Maddy

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,260708#msg-260708)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 2, 2015, 12:06pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/5 "2015-08-02T12:06:13Z")

</div>

On Sat, Aug 01, 2015 at 07:32:42PM -0400, smsmaddy1981 wrote:

Hi there,

> Issue arises, when trying to access services deployed on other servers  
> (2,3,4,5). request is reached via upstream servers configured.  
> Unfortunately, the static content (2,3,4,5) servers are not getting  
> fetched/loaded. Rather, it is trying to find the data on NGINX installed  
> machine only.

I don’t see answers to my previous questions here.

So I’ll try again, with just one question:

When you request [http://ser-01/content/img.jpg](http://ser-01/content/img.jpg), on which of your servers  
1-5 is the file img.jpg located?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 3, 2015, 12:31am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/6 "2015-08-03T00:31:06Z")

</div>

On Sun, Aug 02, 2015 at 05:44:27PM -0400, smsmaddy1981 wrote:

Hi there,

> Yes, the file/s are located. Verified with all servers.

You make a http request for /content/img.jpg.

The file /usr/local/nginx/html/content/img.jpg is on one of your five  
servers.

You seem to report that nginx fails to serve it from the filesystem of  
ser01, because it is actually on one of the other servers.

Which one of your servers contains the file  
/usr/local/nginx/html/content/img.jpg?

Your answer should be one of:

- ser02

- ser03

- ser04

- ser05

- none of them, because I never make a request for /content/img.jpg

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 3, 2015, 12:36am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/7 "2015-08-03T00:36:57Z")

</div>

Answer below pls:

Nginx is on “ser01”  
file is on “ser02”

//Maddy

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,260710#msg-260710)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 3, 2015, 12:46am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/8 "2015-08-03T00:46:53Z")

</div>

On Sun, Aug 02, 2015 at 06:36:13PM -0400, smsmaddy1981 wrote:

> Answer below pls:
> 
> Nginx is on “ser01”  
> file is on “ser02”

How do you know that /content/img.jpg should be served from ser02,  
and not from ser01 or ser03?

What is special about /content/img.jpg that says “this is on ser02”?

(You can configure nginx to know what that special thing is, so that  
things will work as you want.)

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 3, 2015, 1:06am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/9 "2015-08-03T01:06:45Z")

</div>

On Sun, Aug 02, 2015 at 06:59:03PM -0400, smsmaddy1981 wrote:

> “/content/img.jpg” is sepcific to an application and which is deployed on  
> “ser02”.

I’m going to guess that you mean “every request that starts with  
/content/  
should be handled by ser02”.

In that case, your configuration should be like

location ^~ /content/ {  
proxy\_pass [http://ser02](http://ser02);  
}

What happens when you use that?

(What request do you make?; what response do you get?)

> Whenenver an web request is made accessing the application (deployed on  
> ser02)…through upstream configuration…the service responds reaching  
> ser02…but static files (/content/img.jpg) are not rendered. The access\_log  
> shows the file is trying to look on ser01 (Nginx is installed)

If you still see a problem, can you list the exact request that does  
work as you want, and the exact request that does not work as you want?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 3, 2015, 12:59am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/10 "2015-08-03T00:59:44Z")

</div>

“/content/img.jpg” is sepcific to an application and which is deployed  
on  
“ser02”.

Whenenver an web request is made accessing the application (deployed on  
ser02)…through upstream configuration…the service responds reaching  
ser02…but static files (/content/img.jpg) are not rendered. The  
access\_log  
shows the file is trying to look on ser01 (Nginx is installed)

(You can configure nginx to know what that special thing is, so that  
things  
will work as you want.)  
How pls.???

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,260712#msg-260712)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 17, 2015, 11:31am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/11 "2015-08-17T11:31:01Z")

</div>

Hi Francis,  
There were some HW upgrades because of which I was halted to make  
anymore  
trials.

Today, I am revoked the access to continue my investigation and with  
your  
recent suggestion/tip…I am able to access the static content.

Cheers and very kind for your quick support.

Best regards,  
smsmaddy

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,261051#msg-261051)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 18, 2015, 7:13pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/12 "2015-08-18T19:13:42Z")

</div>

Hi Francis,

One more observation pls.

This WORKS in reading static content from remote server  
location ^~/wkspace/ {  
proxy\_pass [http://citwkspace](http://citwkspace);  
}

This DOESN’T WORK? in reading static content from remote server  
location ^~/wkspace/agentLogin/ {  
proxy\_pass [http://citwkspace](http://citwkspace);  
}

Best regards,  
Maddy

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,261105#msg-261105)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 3, 2015, 1:30am UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/13 "2015-08-03T01:30:42Z")

</div>

Hi Francis

Thanks for your quick support, I will revert with my observations.

Regards.  
Maddy

Posted at Nginx Forum:

> **[Re: Static Content on Different Server Isn't Loaded??](https://forum.nginx.org/read.php?2,259786,260714#msg-260714)**
>
> Hi Team, I have static content available on the remote server (say NODE 02) and PATH: ../livetest/WEB-INF/static/classes/ under which I have /image, /js, /styles folders I have installed nginx-1.8.0 on server (Say Node 01). While accessing the appl

---

<div class="post-metadata">

**Author:** ![smsmaddy1981](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@smsmaddy1981](https://www.ruby-forum.com/u/smsmaddy1981)\
**Post date:** [August 19, 2015, 7:34pm UTC](https://www.ruby-forum.com/t/static-content-on-different-server-isnt-loaded/242406/14 "2015-08-19T19:34:09Z")

</div>

On Tue, Aug 18, 2015 at 01:12:54PM -0400, smsmaddy1981 wrote:

Hi there,

> This WORKS in reading static content from remote server  
> location ^~/wkspace/ {  
> proxy\_pass [http://citwkspace](http://citwkspace);  
> }

For the request that works:

what does your nginx log say that the request to nginx was?

what does your citwkspace web server log say that the request to it was?

what file on the citwkspace web server was successfully returned?

> This DOESN’T WORK? in reading static content from remote server  
> location ^~/wkspace/agentLogin/ {  
> proxy\_pass [http://citwkspace](http://citwkspace);  
> }

For the request that does not work:

what does your nginx log say that the request to nginx was?

what does your citwkspace web server log say that the request to it was?

what file on the citwkspace web server did you want to have returned?

what was the response instead?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
