Nginx + uwsgi + django + websocket(dwebsocket)环境部署
map $http_upgrade $connection_upgrade { default upgrade;'' close;
}
server
{
listen 80;
server_name devops.xx.com devops.xx.local;
access_log /export/servers/nginx/logs/devops.xx.local/devops.xx.local_access.log main;
error_log /export/servers/nginx/logs/devops.xx.local/devops.xx.local_error.log warn;
error_page 400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 506 = http://www.jd.com/error2.aspx;
charset utf-8;
# #########################核心配置就这2行#########################################
location / {
include /export/servers/nginx/conf/uwsgi_params;
uwsgi_pass unix:/export/App/DevOPS/Python_20160906/Python_20160906.sock;
}
#################################################################################
location /static/ {
alias /export/App/DevOPS/Python_20160906/static/;
}
# websocket的匹配
location ~ /index/websocket_demo/ {
include /export/servers/nginx/conf/uwsgi_params;
uwsgi_pass unix:/export/App/DevOPS/Python_20160906/Python_20160906.sock;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location = / {
rewrite ^ /index/ permanent;
}
location = /favicon.ico {
rewrite ^ /static/image/favicon.ico permanent;
}
location /devops/ {
rewrite ^/devops/(.*)$ /$1 last;
}
location /software/ {
alias /export/Data/software/;
allow all;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
页:
[1]