Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
I am unable to set nginx to accept domain name
Hi, i am like 3 hours trying to manage to set nginx to use my desired host name, but cant make it working.
If i access my public ip, i see welcome page for “DigitalOcean Rails Application”.
But if access my desired domain, lets say x.y.com where DNS A name leads to my public ip, the address doesnt stay in browser address bar, but it is redirected to public ip.
(And i need to make it stay in browser of course. I am not interested in redirecting to IP from domain name)
I am attaching HTTP response if i access the domain name:
Request URL: http://x.y.com/ Request Method: GET Status Code: 301 Moved Permanently Location:http://<my-public-ip> Server:Varnish Via:1.1 varnish
And btw dont know why it shows Varnish and not Nginx, if i guess there is no Varnish installed. (It is default installation of Ruby on Rails + Nginx)
I tried to edit /etc/nginx/sites-enabled/default
and change server_name from _; to my domain.. no effect, it is still redirecting..
I tried to also add my domain name in /etc/hosts
127.0.0.1 localhost x.y.com
I am fucking crazy from it, and dont know what to do yet.
Here is screen of /etc/nginx/sites-enabled/default configuration which is default by digital ocean.
I wanted also set up reverse proxy for Discourse, because discourse is running on port 8081
Here is some sample setup for reverse proxying discourse and i made it working by placing in sites-enabled/default - discourse worked on public ip, without need to add extra port, but there was problem with the redirecting from domain to IP, so i said to me, i will remove this, and will try to manage the domain problem with just basic default nginx setup. (To just show hello page for domain name, as start).
Thx anyone for 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.×