Jakub
Jakub

Reputation: 2141

Nginx subdomains not working

I don't know what's wrong. I don't get any warnings in logs. I've similar config to this How to exclude specific subdomains server_name in nginx configuration

I want to create subdomain us.example.io I'm using ping to check it

ping us.example.io
ping: cannot resolve us.example.io: Unknown host

nginx.config

 server {
    server_name *. us.example.io us.example.io;
    listen 80;
    root /usr/share/nginx/html/bint;
    index index.html index.htm index.php;
    location / {
      try_files $uri $uri/ /index.html;   
    }
  }

  server {
    server_name us.example.io;
    listen 80;
    return http://www.google.com;
  }

Upvotes: 2

Views: 3918

Answers (2)

user23349058
user23349058

Reputation: 11

Probably you should add the subdomain in the hosts configuration. Edit the file in /etc/hosts and then try again, it should work.

Upvotes: 0

VBart
VBart

Reputation: 15110

The problem has nothing to do with nginx. The error suggests that you haven't configured a DNS record for the domain.

Upvotes: 7

Related Questions