Report this

What is the reason for this report?

How do I change nginx routing on the rails/nginx preconfigured droplet on Ubuntu?

Posted on November 4, 2014

I just installed the nginx/rails configuration with Ubuntu 14.10 and I’m trying to have nginx point to various folders that are separate from rails, but I can’t find any sites-available information, and it seems that /opt/nginx/conf/nginx.conf is also empty.

How can I add a simple route from “domain/stuff” to /var/www/stuff with this premade install?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Edit your server block (it should be in /etc/nginx/sites-enabled) and add the following location block:

location /stuff {
    alias /var/www/stuff; # map /stuff to /var/www/stuff
    index index.html; # assuming /var/www/stuff contain static files only
    try_files $uri $uri/ =404; # requests under /stuff shouldn't be passed to rails
}

Then restart nginx:

sudo service nginx restart

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.