运行 nginx 上有两个以上的 web 应用程序
Running more than two web applications on nginx
在 Ubuntu,我正在尝试 运行 三个使用 nginx 和 uwsgi 的网络应用程序。我能够 运行 两个具有以下 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 nginx
和sudo systemctl restart nginx
。然后它产生了错误说
nginx: [emerg] invalid number of arguments in "location" directive in /etc/nginx/sites-enabled/display-air.conf:7
我做错了什么?任何人都请帮助我。
这里少了一个斜杠
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;
}
在 Ubuntu,我正在尝试 运行 三个使用 nginx 和 uwsgi 的网络应用程序。我能够 运行 两个具有以下 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 nginx
和sudo systemctl restart nginx
。然后它产生了错误说
nginx: [emerg] invalid number of arguments in "location" directive in /etc/nginx/sites-enabled/display-air.conf:7
我做错了什么?任何人都请帮助我。
这里少了一个斜杠
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;
}