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 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:
Request Method: GET

Status Code: 301 Moved Permanently
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 localhost

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.

Configuration link

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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.


I probably found it… damn i was 2hrs struggling with nginx, thinking it is problem of server, but you know where is probably problem?

That the domain is not set proberly as “A name” record, but via some plain redirection from site (domain registar site) to

I found it by “tracert” command of on Windows machine.

Thats probably it.

Will confirm it later.