I am trying to transfer my domain. I am running my rails app using this command from my rails folder
RAILS_ENV=production rails s --binding=128.199.95.219
However, I can only access it through http://128.199.95.219:3000/
but not http://128.199.95.219/
.
I might be wrong but I think I need to somehow serve my app from the root domain address like http://128.199.95.219/
not http://128.199.95.219:3000/
. I have already point my domain name to DigitalOcean by following this tutorial And I have also setup the host name with DigitalOcean. So right now I just need to configure rails, nginx, and unicorn somehow to serve my app at the domain address or http://128.199.95.219/
(I don’t even know if that is what I need to do. so please help me!)
I am running Ubuntu 14.04 with rails, nginx, and unicorn. I’ve configured my nginx and unicorn according to this tutorial here
How do I make rails application accessible from the root of the domain address (http://128.199.95.219/
)? or is that eve necessary at all?
How exactly do I deploy my rails application? I am lost! Please help!
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.
You need to use nginx to proxy HTTP requests to whatever port unicorn is running on. In this specific case that is port 3000.
When you go to any website using a web browser by default http://website.com is actually just sending a request to the IP address at website.com on port 80. Likewise, when you go to https://website.com it is sending a request to that IP address at website.com on port 443.
So, in your case you have unicorn running on port 3000, and you need to get nginx to listen on port 80 and proxy all requests to port 3000.
SSH into your server
Edit the nginx config file
nano /etc/nginx/sites-available/default
Replace everything in there with this:
Restart nginx
service nginx restart
You should now be able to access your rails app at both 128.199.95.219 and assuming you have an A record for
YOUR_WEBSITE.COM
pointed to 128.199.95.219 then you should also be able to access the app athttp://YOUR_WEBSITE.COM
Hope this helps!