gpt4 book ai didi

django - nginx - 在/etc/nginx/sites-enabled/django 中复制上游 "app_server"

转载 作者:行者123 更新时间:2023-12-04 18:43:36 24 4
gpt4 key购买 nike

意外删除 conf nginx 填满 /etc/nginx/sites-enabled/django
,然后用相同的配置设置填充它。得到以下错误:

  Feb 02 12:56:53 solomon nginx[32004]: nginx: [emerg] duplicate upstream "app_server" in /etc/nginx/sites-enabled/django.save:1
Feb 02 12:56:53 solomon nginx[32004]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 02 12:56:53 solomon systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 02 12:56:53 solomon sudo[31990]: pam_unix(sudo:session): session closed for user root
Feb 02 12:56:53 solomon systemd[1]: Failed to start A high performance web server and a reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
Feb 02 12:56:53 solomon systemd[1]: nginx.service: Unit entered failed state.
Feb 02 12:56:53 solomon systemd[1]: nginx.service: Failed with result 'exit-code'.

配置,之前肯定有效。我做错了什么吗?:
 upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.html index.htm;

client_max_body_size 4G;
server_name _;

keepalive_timeout 5;

# Your Django project's media files - amend as required
location /media {
alias /home/django/django_project/django_project/media;
}

# your Django project's static files - amend as required
location /static {
alias /home/django/django_project/django_project/static;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}

最佳答案

如果目录( /etc/nginx/sites-enabled/django )中有其他配置文件,其上游名称与“app_server”相同,那么您会收到重复的上游错误。

因此,将“app_server”替换为任何其他名称。运行 nginx -t检查任何错误,然后重新启动nginx,

关于django - nginx - 在/etc/nginx/sites-enabled/django 中复制上游 "app_server",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42002954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com