몇 시간 동안 사용해 본 적이 있지만 왜 내 설정이 작동하지 않는지 알 수 없습니다. 자체적으로 exec에있는 명령을 실행하면 브라우저를 통해 페이지에 액세스 할 수 있습니다. 하지만 서비스로 실행하려고하면 502 : Bad Gateway가 발생합니다.Nginx + Systemd/Systemctl + Django가 작동하지 않음 (502 불량 게이트웨이)
처음에는 유닉스 소켓을 사용해 보았습니다.하지만 작동하지 않을 때 IP와 포트를 직접 연결 했는데도 여전히 운이 없었습니다.
gunicorn.service :
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=username
WorkingDirectory=/home/username/naomiselect
Environment="PATH=/home/username/naomiselect/naomienv/bin"
ExecStart=/home/username/naomiselect/naomienv/bin/gunicorn --workers 3 --bind local_ip:8000 naomiselect.wsgi:application
[Install]
WantedBy=multi-user.target
nginx.conf :
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
사이트-가능/naomiselect :
server {
listen 80;
server_name local_ip;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/username/naomiselect;
}
location/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://local_ip:8000/;
}
}
디렉토리 그룹과 소유자가 www가 데이터 및 사용자 이름입니다 , 각각 재귀 적으로, 사용 권한 drwxrwxr-x.
몇 가지 자습서를 참조하고 다른 방법을 시도했을 때 내가 무엇을 잘못하고 있는지 전혀 알지 못합니다. 해당 없음이 작동합니다.
502 응답은 업스트림 서버에 연결할 수 없음을 의미합니다. gunicorn이 작동하고 있는지 확인 하시겠습니까? – jedifans
전혀 작동하지 않는다고 생각합니다. 상태는 서비스에 대해 "실행 중"이 아니라 "종료됨"이라고 표시합니다. 왜 그냥 종료하는지 모르겠습니다. – tayoung
'journalctl -xe'에있는 모든 내용이 종료되는 이유는 무엇입니까? – jedifans