Question

Subdomain server block doesn't work

Hello, I’m trying to create a subdomain on my server but it’s not working. I have main domain where i host a wordpress also with Let’s Encrypt certificate, everything through tutorials on this site. My DNS is handled by CloudFlare.

So first i turned off CloudFlare services, now it handles only DNS. I also created a new A DNS record which points to the server IP.

Next i created a link of default server block in sites-enabled folder just to make sure everything is working and it is, when i enter IP of my server in browser, nginx welcome page appears. ( but I had to do it in another browser because chrome always translate ip to main domain name )

In the default server block, I changed server name to my subdomain ( something.something.com ) and when I restarted the nginx service a go to my subdomain it didn’t work, it redirected me to the main domain. So I was trying to solve this problem, I also removed my main domain from enabled sites and it still didn’t work.

But when I change the server name in default server block from subdomain to my main domain (main domain server block is disabled), it works (shows nginx welcome page).

What can be a problem?

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

do you set cname on your cloudflare. or i think it might being issue of htaccess in wordpress

Ok, I decided to get rid of CloudFlare and everything works now.