Nginx config does not work for two subdomains

645 views Asked by At

I'm trying to get the following setup to work with gunicorn and nginx. Everything works until I add the second server config...

upstream app_server_djangoapp {
    server localhost:8002 fail_timeout=0;
}

server {
    listen 80;
    server_name api.domain.tld;
    access_log  /var/log/nginx/guni-access.log;
    error_log  /var/log/nginx/guni-error.log info;

    keepalive_timeout 5;

    # Size in megabytes to allow for uploads.
    client_max_body_size 20M;

    # path for static files
    root /home/username/webapps/guni/static;

    location /docs/  {
                autoindex on;
                alias /srv/site/docs/buildHTML/html/;
    }



    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        if (!-f $request_filename) {
            proxy_pass http://app_server_djangoapp;
            break;
        }
    }

}

server {
    listen 80;
    server_name flower.domain.tld;
    location / {
        proxy_pass http://localhost:5555;
        }

What I'm I doing wrong? I need to have two subdomains one mapped to my django app and other mapped to my monitoring software on 5555 (flower)

log files states:

2014/11/21 12:03:27 [emerg] 962#0: unexpected end of file, expecting "}" in /etc/nginx/sites-enabled/default:47

1

There are 1 answers

0
Laura On BEST ANSWER

Your code is missing a closing "}" at the very end:

server {
    listen 80;
    server_name flower.domain.tld;
    location / {
        proxy_pass http://localhost:5555;
    }
}

For future reference: You can run nginx -t (with sudo if needed) to test the configuration before reloading nginx - this will give you a quite good description of any errors you might have in your configuration file(s).