Last Updated: February 25, 2016
· vickeeyz

Nginx Proxy with Unicorn

Unicorn proxy with Nginx

  • This article assumes you already have installed nginx, if not you can install nginx using
sudo apt-get install nginx
  • Download the nginx.conf and sites-available conf from my repo
cd /etc/nginx/
cd /etc/nginx/sites-available/

NOTE: Make sure to open and edit the conf to replace appname with your appname

Goto to nginx/sites-enabled directory and create a symlink to sites-available conf

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/appname appname

Restart nignx

sudo service nginx restart

For Unicorn configurations

place the unicorn.rb in the app/config/

cd /home/user/sites/appname/config/
  • create a unicorn directory in /etc
sudo mkdir /etc/unicorn 

download the app.conf file in /etc/unicorn

cd /etc/unicorn/

modify it as per your requirement

sudo nano /etc/unicorn/app.conf

download the script in /etc/init.d/

cd /etc/init.d/

save the script with name unicorn

make the unicorn init script executable

chmod +x /etc/init.d/unicorn
update-rc.d unicorn defaults

Now start the unicorn service

sudo service unicorn restart