Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to set up a site that has multiple subdomains with nginx. I.e. I want to have a main site at 'sitename.io', a photoblog at 'camera.sitename.io', a resume at 'resume.sitename.io', etc

I currently have a Ghost blog being tested, and it is run at the main site: obscur.io, and it is administered as a site through the sites-enabled subdirectory of nginx. It's conf looks like this:

server {
    listen 80;
    server_name *.obscur.io;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}

And all is fine with it. I have just a skeleton site setup for what I want to be 'camera.obscur.io', but when I use the camera.conf file in sites-enabled below, nginx won't start and returns an error due to a failed state.

server {
    listen 80;
    server_name     camera.obscur.io;

    location / {
        root /home/camera/camera;
        index index.html index.htm;
    }
}

However, I have noticed that if I change the subdomain to anything that is four characters or shorter, such as 'nice.obscur.io' or 'www.obscur.io', both sites run well side-by-side and direct properly.

So how can I make my second site with a subdomain more than four characters long? And why is this limitation there?

I have tried adding an A record for camera that redirects, having a wildcard A record, and neither work. I'm pretty new to this.

Thank you in advance for any help!


EDIT

I figured out ONE way to make it work; instead of giving a very specific subdomain prefixed to the domain proper (i.e. camera.obscur.io) I made a wildcard for the subdomain:

server_name camera.*

and removed the wildcard for the main domain:

server_name obscur.io

This fixed my problem, but it still doesn't explain why a subdomain of more than four characters would case the nginx process to not start.

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.