环境 django + nginx + uwsgi + https
先申请阿里云SSL证书
然后补充信息等待申请成功
申请成功之后点击 下载
下载完成之后会得到两个后缀名为
.key .pem
文件在阿里云服务器新建cert文件夹
mkdir cert
将文件上传到阿里云服务器
/etc/nginx/cert/
更改
nginx.conf
配置如下
server {
listen 80;
server_name www.1117.work;
rewrite ^/(.*) https://www.1117.work/$1 permanent;
}
server {
listen 443 ssl;
server_name www.1117.work; # 写你自己的域名
access_log /var/log/nginx/example.com_access.log combined;
error_log /var/log/nginx/example.com_error.log error;
ssl_certificate /etc/nginx/cert/你自己的文件名.pem;
ssl_certificate_key /etc/nginx/cert/你自己的文件名.key;
location /static {
alias /home/blog/static_files;
}
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
网友评论