# Static content

**URL:** <https://www.ruby-forum.com/t/static-content/242526>\
**Category:** NGINX\
**Created:** [June 30, 2015, 1:20pm UTC](https://www.ruby-forum.com/t/static-content/242526 "2015-06-30T13:20:16Z")\
**Posts on this page:** 5\
**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 30, 2015, 1:20pm UTC](https://www.ruby-forum.com/t/static-content/242526/1 "2015-06-30T13:20:16Z")

</div>

Hi,  
I have NGinx 1.8.0 installed successfully and configured NGinx… with  
upstream servers provided. NGinx and Services are deployed on separate  
machines. Now, when an request is made via NGinx, the service is invoked  
resulting in UI with no static content loaded.

I have tried root, rewrite directives… to specify the static content  
path  
on another server (workspace.corp.test.no), which didn’t helped. I might  
be  
wrong with configuration. Pls. assist

```
server {
   listen 80;
   server_name workspace.corp.test.no;

   location ~"*\.(js|jpg|png|css)$" {
       root /workspace/WEB-INF/classes/static;
       expires 30d;
   }

   location /{
      proxy_pass 

```

[http://workspace.corp.test.no/workspace/agentLogin/](http://workspace.corp.test.no/workspace/agentLogin/);  
}  
}

And, the above configuration is expecting static content on the server  
where  
NGinx is installed, when an request is made. But, I expect the static  
content to be expected from remote server.

Best regards,  
Maddy

Posted at Nginx Forum:

> **[Static content](https://forum.nginx.org/read.php?2,259989,259989#msg-259989)**
>
> Hi, I have NGinx 1.8.0 installed successfully and configured NGinx... with upstream servers provided. NGinx and Services are deployed on separate machines. Now, when an request is made via NGinx, the service is invoked resulting in UI with no static...

---

<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 30, 2015, 4:37pm UTC](https://www.ruby-forum.com/t/static-content/242526/2 "2015-06-30T16:37:09Z")

</div>

On Tue, Jun 30, 2015 at 12:19 PM, smsmaddy1981 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> proxy_pass http://workspace.corp.test.no/workspace/agentLogin/;
> }
> }
> 
> ```
> 
> And, the above configuration is expecting static content on the server where  
> NGinx is installed, when an request is made. But, I expect the static  
> content to be expected from remote server.

That is the problem! You’re telling it the static content is in the  
local system at ‘/workspace/WEB-INF/classes/static’ when its not…

Assuming the “frontend” is proxying to another nginx server you  
should only define “location ~”\*.(js|jpg|png|css)$" {" in the ‘inner’  
(for lack of a better term) nginx server.

---

<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 30, 2015, 11:05pm UTC](https://www.ruby-forum.com/t/static-content/242526/3 "2015-06-30T23:05:07Z")

</div>

Hi Mike  
Thanks for your reply  
I did not understand your suggestion. Can you please elaborate with an  
example

Regards,  
Maddy

Posted at Nginx Forum:

> **[Re: Static content](https://forum.nginx.org/read.php?2,259989,260003#msg-260003)**
>
> Hi, I have NGinx 1.8.0 installed successfully and configured NGinx... with upstream servers provided. NGinx and Services are deployed on separate machines. Now, when an request is made via NGinx, the service is invoked resulting in UI with no static...

---

<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:** [July 7, 2015, 1:08pm UTC](https://www.ruby-forum.com/t/static-content/242526/4 "2015-07-07T13:08:35Z")

</div>

Hi Mike

Thanks for your quick reply…

To answer your questions:

- Upstream servers yes (where applications are deployed). And, not  
NGinx  
installations.
- I tried accessing the static content on other servers, that isn’t  
working… I tried using root, rewrite,… directives.

Is it possible to share an code snippet to achieve this use case pls.?

Regards,  
Maddy

Posted at Nginx Forum:

> **[Re: Static content](https://forum.nginx.org/read.php?2,259989,260112#msg-260112)**
>
> Hi, I have NGinx 1.8.0 installed successfully and configured NGinx... with upstream servers provided. NGinx and Services are deployed on separate machines. Now, when an request is made via NGinx, the service is invoked resulting in UI with no static...

---

<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 30, 2015, 11:50pm UTC](https://www.ruby-forum.com/t/static-content/242526/5 "2015-06-30T23:50:41Z")

</div>

You said it yourself:  
“And, the above configuration is expecting static content on the server  
where  
NGinx is installed, when an request is made. But, I expect the static  
content to be expected from remote server.”

Nginx expets the file to be on the server, and that’s how it works…  
you need to either make them available in that server, in the path  
you’re specifing or just “drop” that location block in this server.

Are you’re upstream server other nginx servers?

Melhores Cumprimentos // Best Regards
