# Nginx static files

**URL:** <https://www.ruby-forum.com/t/nginx-static-files/236686>\
**Category:** NGINX\
**Created:** [September 25, 2013, 10:18am UTC](https://www.ruby-forum.com/t/nginx-static-files/236686 "2013-09-25T10:18:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 25, 2013, 10:18am UTC](https://www.ruby-forum.com/t/nginx-static-files/236686/1 "2013-09-25T10:18:14Z")

</div>

I have a rails server and I would like to serve all this static files \*.  
jpg, \*. png, \*. css, \*. js, \*. gif, \*. jpeg with nginx

This is my actual configuration

server {  
listen 443;  
server\_name [emotionalworld.co](http://emotionalworld.co) [www.emotionalworld.co](http://www.emotionalworld.co);  
rewrite ^ http://$server\_name$request\_uri? permanent; # enforce https  
}

server {  
listen 80;  
server\_name [emotionalworld.co](http://emotionalworld.co) [www.emotionalworld.co](http://www.emotionalworld.co);

access\_log /var/log/nginx/chili-proxy-access;  
error\_log /var/log/nginx/chili-proxy-error;

expires epoch;

include includes/proxy.include;  
proxy\_redirect off;

root /home/jaranda/jaranda-emotionalworld;

# Send sensitive stuff via https

# rewrite ^/login(.\*) https://your.domain.here$request\_uri permanent;

# rewrite ^/my/account(.\*) https://your.domain.here$request\_uri

permanent;

# rewrite ^/my/password(.\*) https://your.domain.here$request\_uri

permanent;

# rewrite ^/admin(.\*) https://your.domain.here$request\_uri permanent;

location / {

# auth\_basic “Acceso de solo invitados”;

# auth\_basic\_user\_file /etc/nginx/htpasswd;

try\_files $uri/index.html $uri.html $uri @fallback;  
}

location @fallback {  
proxy\_pass [http://127.0.0.1:9000](http://127.0.0.1:9000);

# proxy\_set\_header X-Forwarded-Protocol https;

# proxy\_connect\_timeout 15;

# proxy\_redirect off;

# proxy\_set\_header Host $host;

# proxy\_set\_header X-Real-IP $remote\_addr;

# proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

# proxy\_set\_header X-Forwarded-Proto https;

}

}

---

<div class="post-metadata">

**Author:** ![pacolotero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/53a042/32.png) [@pacolotero](https://www.ruby-forum.com/u/pacolotero)\
**Post date:** [September 25, 2013, 2:35pm UTC](https://www.ruby-forum.com/t/nginx-static-files/236686/2 "2013-09-25T14:35:07Z")

</div>

On 25 Sep 2013 09:18, “pacolotero pacolotero” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have a rails server and I would like to serve all this static files \*.  
> jpg, \*. png, \*. css, \*. js, \*. gif, \*. jpeg with nginx
> 
> This is my actual configuration

You appear to have forgotten to ask a question!

I mean, I assume you’ve already tried some things out and aren’t just  
expecting someone to write the new config for you … 😉

Jonathan
