Nginx+uwsgi+Django (
Nginx+uwsgi+Django (python WEB环境)
nginx配置文件
[root@DB02 rc3.d]# vi /application/nginx/conf/nginx.conf
user root;
worker_processes 1;
events {
worker_connections 1024;
}
#}
Http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream djanGo {
server unix:///tmp/project.sock; # for a file Socket
}
server {
listen 80;
server_name da.yilongzc.com;
location /static {
alias /root/shell/DataShow/static; # your Django project's static files - amend as required
send_timeout 500;
proxy_read_timeout 500;
proxy_connect_timeout 500;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
root /root/shell/DataShow/;
if (-f $request_filename) {
expires 1d;
break;
}
}
location ~ .*\.(js|CSS)$
{
root /root/shell/DataShow/;
if (-f $request_filename) {
expires 1d;
break;
}
}
location / {
uwsgi_send_timeout 500;
uwsgi_connect_timeout 500;
proxy_read_timeout 500;
uwsgi_read_timeout 500;
uwsgi_ignore_client_abort on;
uwsgi_pass django;
include uwsgi_params;
}
}
}
通过/tmp/project.sock 文件,将nginx与uwsgi关联,进行通信
注意:要放到/tmp 下,否则会报403 没有权限
nginx配置文件中的超时时间,是为了解决504 time-out文件,主要是因为后端Python环境,请求数据时,没有在指定时间内返回数据,所以出现这个问题,运维这边只能调整超时参数,或者找开发去优化sql语句,在或者拆分他们的业务,将1个页面,分成多个小页面去请求
相关文章