Hello, I followed a guide to making subdomains in nginx and created a new server block with the server name pointing to my subdomain (api.test.com) However when I go to the address, it shows the contents of test.com. Any ideas on what the problem is?
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!
server { <br> listen 80 default_server; <br> listen [::]:80 default_server ipv6only=on; <br> <br> root /usr/share/nginx/html/main; <br> index index.html index.htm index.php; <br> <br> # Make site accessible from http://localhost/ <br> server_name localhost; <br> include hhvm.conf; <br> <br> location / { <br> # First attempt to serve request as file, then <br> # as directory, then fall back to displaying a 404. <br> try_files $uri $uri/ /index.html; <br> # Uncomment to enable naxsi on this location <br> # include /etc/nginx/naxsi.rules <br> } <br> <br> location /doc/ { <br> alias /usr/share/doc/; <br> autoindex on; <br> allow 127.0.0.1; <br> allow ::1; <br> deny all; <br> } <br>} <br> <br>server { <br> listen 80; <br> listen [::]:80; <br> <br> root /usr/share/nginx/html/api; <br> index index.html index.htm index.php; <br> <br> # Make site accessible from http://localhost/ <br> server_name api.airiverse.com; <br> include hhvm.conf; <br>} <br>
Your configuration looks fine. But maybe you get error because of listen [::]:80 default_server ipv6only=on; and listen [::]:80; are enabled which are for ipv6. DO currently don’t support ipv6. Try to comment those 2 and restart nginx. Also have you added the subdomain in your DNS?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.