Hello this is my first time deploying rails app to a ubuntu server so after I configured nginx and got the "welcome to nginx page"
at a certain IP ... and when I start rails application I must enter the port in the IP address for example 165.217.84.11:3000
in order to access rails so how to make rails run default when I run only this IP 165.217.84.11
Asked
Active
Viewed 618 times
2

Tachyons
- 2,131
- 1
- 21
- 35

john meichn
- 23
- 2
2 Answers
1
You can set the redirection from the 80 port (wich is the default) to the 3000 like this:
worker_processes 1;
events { worker_connections 1024; }
http {
client_max_body_size 10m;
sendfile on;
upstream rails {
server 165.217.84.11:3000;
}
server {
listen 80;
location / {
proxy_pass http://rails-app;
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 $scheme;
proxy_set_header X-Forwarded-Ssl off;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
So, when you access 165.217.84.11 in the browser you should see your rails project.

Eric Nordelo Galiano
- 445
- 4
- 15
-
thanks for your answer it almost works but there is a problem : it runs on `165.217.84.11.COM/index` so how can i get rid of this `.com` ( both `upstream rails` and `proxy_pass` are set to `165.217.84.11:3000` ( I don't yet have a domain name ) – john meichn Aug 30 '18 at 02:05