Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

On ec2 I have the parent domain e.g. . I want to setup a subdomain on EC2 which is currently hosting - a subdomain like is running nginx, with a sites-enabled config of:

server {
        listen       80;
        server_name     *;
        root /home/ubuntu/virtualenv/somedomain/somedomain/homelaunch/;

        access_log /home/ubuntu/virtualenv/somedomain/error/access.log;
        error_log /home/ubuntu/virtualenv/somedomain/error/error.log warn;
        connection_pool_size 2048;

        fastcgi_buffer_size 4K;
        fastcgi_buffers 64 4k;

        location /static {
            alias /home/ubuntu/virtualenv/somedomain/somedomain/homelaunch/static/;

        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 10;
            proxy_connect_timeout 10;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';

the is perfectly accessible using EC2, I would like to know how to include a subdomain like to the picture and serve different content.

Thank you.

share|improve this question
What is the problem you are having? – Michael Hampton Dec 4 '13 at 22:23
up vote 1 down vote accepted

You can just add an extra "server" block with the exact domain name you wish to serve.

As pointed out in the server_name documentation, the exact name takes precedence over wildcard names.

That effectively means that if you add something like this above or below the existing block, you should get the desired result.

server {
    listen       80;
share|improve this answer
Do I need to then reinstall everything again on this ? e.g. django, etc? – user700070 Dec 4 '13 at 22:50
Additionally, does this require me to restart nginx to take effect? – user700070 Dec 4 '13 at 22:52
Regarding nginx, if you don't change the listen port then no, you can just reload the configuration. service nginx reload will do in most Linux systems. Regarding python and Django, I guess that it will be running behind a different gunicorn/uwsgi process, so you just have to direct the proxy_pass statement to the correct django instance. – user76776 Dec 4 '13 at 22:54
@user700070 Django will operate with the proxy_pass directive, fyi. – Nathan C Dec 4 '13 at 22:55
okay, excellent. Thank you both! – user700070 Dec 4 '13 at 23:11

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.