在nginx上运行两个以上的Web应用程序

时间:2017-11-18 06:58:17

标签: nginx uwsgi

在Ubuntu上,我试图使用nginx和uwsgi运行三个Web应用程序。我能够运行两个具有以下nginx配置的应用程序,但是不能成功运行第三个。请帮我怎么运行它。

首先是nginx配置:air-quality.conf

server {
    listen 80;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.1;
    server_name localhost;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/html/air-quality/socket.sock;
        uwsgi_modifier1 30;
    }

    error_page 404 /404.html;
    location = /404.html {
        root /usr/share/nginx/html;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html{
        root /usr/share/nginx.html;
    }
}

没有问题,上面的配置计算出来并显示210.123.33.247:80/airData上的输出。 第二个nginx配置在items-rest.conf中。它是:

server {
    listen 81;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.1;
    server_name localhost;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/html/items-rest/socket.sock;
        uwsgi_modifier1 30;
    }

    error_page 404 /404.html;
    location = /404.html {
        root /usr/share/nginx/html;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html{
    root /usr/share/nginx.html;
    }
}

它还显示了210.123.33.247:81/items上的预期输出。 但第三个没有用。配置文件是:

server {
    list en 8090;
    real_ip_header X-Forwarded-For;
    set_real_ip_from 127.0.0.1;
    server_name localhost;

    location {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/html/display_air/socket.sock;
        uwsgi_modifier1 30;
    }

    error_page 404 /404.html;
    location = /404.html {
        root /usr/share/nginx/html;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html{
        root /usr/share/nginx.html;
    }
}

在尝试运行第三个应用程序时,我尝试了sudo systemctl reload nginxsudo systemctl restart nginx。然后它产生了错误说

  

nginx:[emerg]" location"中的参数数量无效/etc/nginx/sites-enabled/display-air.conf:7中的指令

我做错了什么?有人请帮帮我。

1 个答案:

答案 0 :(得分:0)

你在这里错过了一个斜杠

location {
    include uwsgi_params;
    uwsgi_pass unix:/var/www/html/display_air/socket.sock;
    uwsgi_modifier1 30;
}

应该是

location / {
    include uwsgi_params;
    uwsgi_pass unix:/var/www/html/display_air/socket.sock;
    uwsgi_modifier1 30;
}
相关问题