在nginx上运行两个以上的web应用程序
问题描述:
在Ubuntu上,我试图运行三个使用nginx和uwsgi的web应用程序。我能够使用以下nginx配置运行两个应用程序,但不能运行第三个应用程序。请帮助我如何运行它。在nginx上运行两个以上的web应用程序
首先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 nginx
和sudo systemctl restart nginx
。然后,它产生的错误说
nginx的:在/etc/nginx/sites-enabled/display-air.conf:7
[EMERG]在 “位置” 指令参数无效号码是什么我做错了吗?任何人都请帮助我。
答
你在这里
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;
}
多么愚蠢的错误。你很棒!你救了我很多痛苦。谢谢你,尼斯。 –
感谢您的帮助,我能够运行第三个应用程序。但是当我从网络(210.123.33.247:8090)登录时,发生内部服务器错误。你能猜到为什么会发生?当我独立运行应用程序时,即不通过nginx或uwsgi,它可以正常工作。这意味着该程序没有错误,对吗?还有什么可能是这个问题? –