server {
#虚拟主机监听端口号
listen 8002;
#虚拟主机 监听IP
server_name 你的外网IP;
root html;
#charset koi8-r;
#虚拟主机日志打印路径
access_log /root/python/source-alpha/product/logs/host.access.log main;
#虚拟主机所有拦截交给 django 处理
location / {
include uwsgi_params;
#注意,此处IP和端口号要与 django 启动服务IP和端口号一至
uwsgi_pass 172.16.0.4:8001;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# 设置Django 静态文件访问
location /static/ {
alias /root/python/product/static/;
#index index.html index.htm;
}
# 设置Django 静态文件访问
location /files/ {
alias /root/python/product/files/;
}
}
【注】
当我们更改配置文件后记住一定要
nginx -t
一定要测试一下配置文件格式是否正确
网友评论