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

March 16, 2015 1.8k views
Nginx Debian Ruby

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

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;
Have another answer? Share your knowledge.

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