Nginx配置不适用于两个子域

时间:2014-11-21 12:10:28

标签: python django nginx gunicorn flower

我正在尝试使用gunicorn和nginx进行以下设置。一切正常,直到我添加第二个server配置...

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;
        }

我做错了什么?我需要有两个子域,一个映射到我的django应用程序,另一个映射到我的监控软件5555(花)

日志文件状态:

  

2014/11/21 12:03:27 [emerg] 962#0:意外的文件结束,期待   / etc / nginx / sites-enabled / default中的“}”:47

1 个答案:

答案 0 :(得分:2)

您的代码缺少结束"}"在最后:

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

供将来参考: 您可以在重新加载nginx之前运行nginx -t(如果需要,使用sudo)来测试配置 - 这将为您提供对配置文件中可能存在的任何错误的非常好的描述。

相关问题