我在/etc/nginx/sites-enabled/nginx.conf
cat /etc/nginx/sites-enabled/nginx.conf
server {
# Redirect all www.project.com requests to project.com
listen 80;
server_name www.******.co;
return 301 http://*******.co$request_uri;
}
server {
listen 80;
server_name ******.co;
location /admin/media/ {
# this changes depending on your python version
root /home/ubuntu/.virtualenvs/sos/lib/python2.7/site-packages/django/contrib;
}
location /static/admin {
autoindex on;
root /home/ubuntu/.virtualenvs/sos/lib/python2.7/site-packages/django/contrib;
}
location /static/ {
autoindex on;
expires max;
alias /home/ubuntu/codebase/static_files/;
}
location / {
# This section is to redirect all http traffic to https if desired
# if ($http_x_forwarded_proto != 'https') {
# rewrite ^ https://$host$request_uri? permanent;
# }
client_max_body_size 5M;
client_body_buffer_size 128k;
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_pass http://127.0.0.1:8000/;
}
# what to serve if upstream is not available or crashes
error_page 500 502 503 504 /home/ubuntu/codebase/static_files/500.html;
}
我已通过gunicorn
安装pip install gunicorn
并将其放入django settings'* installed_apps *。
如上所述here我运行python manage.py run_gunicorn它没有给出任何错误,但是当我打开我的网站时,我得到了
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
我确信gunicorn正在运行,因为以下内容 -
ps aux | grep gunicorn
ubuntu 1819 0.0 0.4 121928 16944 ? S 22:08 0:00 python manage.py run_gunicorn -D
ubuntu 1822 0.0 0.7 136264 29556 ? S 22:08 0:00 python manage.py run_gunicorn -D
ubuntu 2017 0.0 0.0 8172 944 pts/3 S+ 22:31 0:00 grep --color=auto gunicorn
任何想法,出了什么问题?在过去的8个小时里,我一直在挣扎着。