通过阿里云申请SSL证书
进入域名控制台,选择 SSL证书
下载证书
进入SSL控制台
解压证书
配置nginx
# http:// 默认监听80端口
# 配置这个server的目的是当用户访问www.ieesee.com时指向的是http://www.ieesee.com,
# 使该链接能重定向到https://www.ieesee.com
server {
listen 80;
server_name _;
return 301 https://www.xxx.com$request_uri;
}
# https:// 默认监听443端口,主要访问静态页面
server {
listen 443 ssl;
server_name _;
ssl on;
ssl_certificate xxx.pem;
ssl_certificate_key xxx.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /a/b/c/d/n;
index index.html index.htm;
}
}
# django服务接口通过加密的8080端口调取 https://www.ieesee.com:8080/interface/
server {
listen 8080 ssl;
server_name _;
ssl on;
ssl_certificate xxx.pem;
ssl_certificate_key xxx.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# uwsgi启动django
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
}
}
配置uwsgi
安装
$ pip install uwsgi
项目目录下创建 *.ini 配置文件
[uwsgi]
socket=127.0.0.1:8000
chdir=/xxx/xxx/xxx # 项目路径
module=xxx.wsgi:application
processes=3
master=True
pidfile=/tmp/uwsgi.pid # 使用该文件操作uwsgi
vacuum=True
daemonize=/var/log/uwsgi/uwsgi.log # 日志文件
stats=/tmp/uwsgi.status
uwsgi基本操作
$ uwsgi --ini *.uwsgi.ini # 启动
$ uwsgi --stop /tmp/uwsgi.pid # 停止
$ uwsgi --reload /tmp/uwsgi.pid # 重载
$ uwsgi --connect-and-read /tmp/uwsgi.status # 查看状态