为什么nginx运行默认页面?怎么听我的django服务器?
首先在我创建sites-availabe
文件的example.com
文件夹内,然后我
[root@instance-4 sites-available]# ls -al /etc/nginx/sites-enabled/example.com
lrwxrwxrwx. 1 root root 21 Dec 22 11:03 /etc/nginx/sites-enabled/example.com -> example.com
/etc/nginx/sites-available/example.com
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
然后当我在我的app文件夹中运行gunicorn example.wsgi
之后我访问了example.com
,但你知道我还在获得nginx默认页面。
我在这里缺少什么?
已更新:
现在这次我在我的Django根文件夹中创建了example.com文件,之后是Symlink
[root@instance-4 Staging]# ln -s example.com /etc/nginx/sites-enabled/
在nginx重启后仍然相同......
更新2 :
nginx.conf文件
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
include /etc/nginx/sites-enabled/*;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
答案 0 :(得分:1)
检查default
中的/etc/nginx/site-enabled/
并将其删除(如果有的话)。然后重新加载或重新启动您的nginx服务器。
您还可以访问example.com:8000
查看gunicorn是否正在处理请求。
值得注意的是,您可能还希望nginx能够提供静态文件,因此请放入/static/
块:
location /static/ {
alias /path/to/your/app/static/;
if ($query_string) {
# If using GET params to control versions, set to max expiry.
expires max;
}
access_log off;
}
答案 1 :(得分:0)
从我记得的nginx,有2个地方你可以找到nginx的index.html,尝试做一个“find / -name index.html”你会发现第二个.html我说的是,关于路径你应该能够解决这个问题