Static Content on Different Server Isn't Loaded?

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:

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) or alias
(Module ngx_http_core_module) are probably most interesting –
and requests that should be proxy_pass’ed to another web server
(Module ngx_http_proxy_module) and requests that should be
fastcgi_pass’ed to a fastcgi server (Module ngx_http_fastcgi_module)
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. [email protected]

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

Hi Francis,

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

Best regards,
Maddy

Posted at Nginx Forum:

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, on which of your servers
1-5 is the file img.jpg located?

f

Francis D. [email protected]

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

    f

    Francis D. [email protected]

Answer below pls:

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

//Maddy

Posted at Nginx Forum:

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. [email protected]

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;
}

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. [email protected]

“/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:

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:

Hi Francis,

One more observation pls.

This WORKS in reading static content from remote server
location ^~/wkspace/ {
proxy_pass http://citwkspace;
}

This DOESN’T WORK? in reading static content from remote server
location ^~/wkspace/agentLogin/ {
proxy_pass http://citwkspace;
}

Best regards,
Maddy

Posted at Nginx Forum:

Hi Francis

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

Regards.
Maddy

Posted at Nginx Forum:

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;
}

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;
}

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. [email protected]