Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 3 subdomains:,, configured by domain provider as following:

Name TTL Type  Value
a    1d  CNAME @
b    1d  CNAME @
c    1d  CNAME @

And the nginx configuration of the service, that should be on the subdomain a:

server {
  listen 80;
  server_tokens off;
  root /nowhere;
  rewrite ^$request_uri permanent;

server {
  listen 443;
  server_tokens off;
  # ssl staff and normal config

So the is forwarded to Other subdomains are not configured. But somehow and are redirected to and, are not redirected.

Why it looks like there are no server_name setting in nginx config? I would like to have many subdomains on my nginx server

share|improve this question
Based on the configuration its because is the default rule. To avoid the behavior you experienced define the rule for the other domains. – Ramhound Jun 24 '13 at 15:11
so the default rule - do the same redirect for all subdomains? But I did explicitly only server { ... server_name; } – static Jun 24 '13 at 15:13
Have you tried to create a rule for those other domains. Your statement is also confusing, might want to read it again, and clarify the statement. – Ramhound Jun 24 '13 at 15:23
@static When nginx receives a request for a domain for which it has no configuration (such as, it uses the configuration for the first server block it finds: In this case "rewrite the domain to"; The end result is is rewritten to Write up configuration for before asking about why it isn't working. – Darth Android Jun 24 '13 at 15:40
But the is not in the config and it opens the default nginx welcome-page. Why the cannot do the same (show the default nginx page)? – static Jun 25 '13 at 13:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.