6.django restframework deploy the project to the ubuntu18.04 (domain configuration and https)

1. The domain name purchase

1. Tencent cloud buy a domain name

2. The domain name for the record

2. DNS

1. Tencent cloud console, select the domain management, and then select DNS

2. Test domain name resolution is successful, open cmd locally.

ping domain

3. Request a free SSL certificate

1. Tencent cloud search ssl, then pick the free ssl certificate, enter the relevant authentication information, waiting for validation

2. Download to a local

4.nginx install ssl certificate

1. Tencent cloud nginx installation documentation ssl certificates:

https://cloud.tencent.com/document/product/400/35244

2. Tencent cloud document

If the / usr / local / nginx / conf directory exists, 1_www.xxxx.com_bundle.crt certificate file and 2_www.xxxx.com.key private key file copied to this directory from the local directory. 
If not, then mkdir build / usr / local / nginx / conf directory

3. filezilla can only be connected to the identity of ubuntu with the cloud server, so only first certificate file and private key file uploaded to ubuntu directory

4. Copy the certificate and the key file to the directory conf

cp 1_www.luoyikeji.cn_bundle.crt /usr/local/nginx/conf
cp 2_www.luoyikeji.cn.key  /usr/local/nginx/conf
cd /usr/local/nginx/conf

5. Edit /etc/nginx/sites-available/gg.conf

 

server{
  listen 443;
  server_name www.luoyikeji.cn;
  charset utf-8;

  ssl on;
  ssl_certificate /usr/local/nginx/conf/1_www.luoyikeji.cn_bundle.crt; #证书文件名称
  ssl_certificate_key /usr/local/nginx/conf/2_www.luoyikeji.cn.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;

  client_max_body_size 75M;

  location /static {
    alias /home/ubuntu/gg/static;
  }
  location /media {
    alias /home/ubuntu/gg/media;
  }

  location / {
    uwsgi_pass 127.0.0.1:8000;
    include /etc/nginx/uwsgi_params;
  }
}

server {
listen 80;
server_name www.luoyikeji.cn; #填写绑定证书的域名
rewrite ^(.*)$ https://$host$1 permanent; #把http的域名请求转成https
}

 

 

6.重启nginx

nginx -t
service nginx restart

 

 7.测试访问:

https://www.luoyikeji.cn/xadmin/

 

 

Guess you like

Origin www.cnblogs.com/xuepangzi/p/11122243.html