How do I set-up reverse proxying with a Ruby Rack app?

Posted March 16, 2015 2.9k views

Are there any good link/resources deploying a Rack app(Not rails!).

So far I have the Rack app set-up with the folders and such but I have been having LOTS of trouble with the nginx part so I uninstalled and decided to try again.

Maybe someone here give me a good dumbed-down version to do this task?

Thanks in advance

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.

Submit an Answer
1 answer

Sure thing! Here is the simplified setup for nginx as a proxy to your ruby app.

Install nginx:

apt-get update;
apt-get install nginx

Then in your main virtualhost configuration: /etc/nginx/sites-enabled/default

Replace the existing Location / block with the following:

location / {
    proxy_pass       http://localhost:4567;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;

Making sure to change 4567 to the port your app is running on if it is different. Then restart nginx so your changes will take effect:

service nginx restart;