How to configure ngnix for rails port?
How to configure ngnix for rails port?
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
"welcome to nginx page"
165.217.84.11:3000
165.217.84.11
2 Answers
2
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.
165.217.84.11.COM/index
.com
upstream rails
proxy_pass
165.217.84.11:3000
In general you have to setup your nginx to use puma socket file and then it will access the website using socket file instead of using TCP port (:3000
by the default).
:3000
Here is a nice tutorial: link
And here is a short explanation why you should use sockets.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
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
( bothupstream rails
andproxy_pass
are set to165.217.84.11:3000
( I don't yet have a domain name )– john meichn
Aug 30 at 2:05