这是出于学习目的。我用Django + Celery / RabbitMQ完成了Web应用程序。我试着关注this教程。我把所有东西都设置好,直到"这就是枪炮的全部。" 。从某种意义上说,我的Gunicors就像教程中描述的那样运行。
现在我对NGINX设置感到困惑。
我在http块中的/etc/nginx/nginx.conf中有这些配置。
upstream awesome_app {
server unix:/home/notalentgeek/Downloads/awesome_app/run/gunicorn.sock fail_timeout=10s;
}
server {
listen 8080;
client_max_body_size 4G;
access_log /home/notalentgeek/Downloads/awesome_app/logs/nginx-access.log;
error_log /home/notalentgeek/Downloads/awesome_app/logs/nginx-error.log warn;
location /static/ {
autoindex on;
alias /home/notalentgeek/Downloads/awesome_app/static/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://awesome_app;
break;
}
}
}
其他一切都保持不变。
然后我应该怎么做?该教程没有任何意义。如何查看我的Web应用程序?此外,如何为Docker准备好NGINX?
编辑:随着Gunicorn的运行与否,使用sudo service nginx start
启动NGINX会出现此错误。
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has begun starting up.
sep 27 17:23:48 notalentgeek-ThinkPad-X220 nginx[28260]: nginx: [emerg] open() "/home/notalentgeek/Downloads/awesome_app/logs/nginx-access.log" failed (2: N
sep 27 17:23:48 notalentgeek-ThinkPad-X220 nginx[28260]: nginx: configuration file /etc/nginx/nginx.conf test failed
sep 27 17:23:48 notalentgeek-ThinkPad-X220 systemd[1]: nginx.service: Control process exited, code=exited status=1
sep 27 17:23:48 notalentgeek-ThinkPad-X220 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.
sep 27 17:23:48 notalentgeek-ThinkPad-X220 systemd[1]: nginx.service: Unit entered failed state.
sep 27 17:23:48 notalentgeek-ThinkPad-X220 systemd[1]: nginx.service: Failed with result 'exit-code'.
sep 27 17:23:48 notalentgeek-ThinkPad-X220 sudo[28225]: pam_unix(sudo:session): session closed for user root
答案 0 :(得分:1)
需要事先创建错误和访问日志。在此之后我的网站运行良好。