nginx指定配置文件

关闭nginx

service nginx stop

设置一个配置文件 order.conf

server {
        listen 80 default_server;
        listen 443 default_server;
        server_name www.xxx.cn;


        location /static {
                alias  /home/ubuntu/data/www/food_order/web/static/;
        }

        location / {
                try_files $uri @yourapplication;
        }
      location @yourapplication {
      include uwsgi_params;
      uwsgi_pass unix:/home/ubuntu/data/www/logs/order.sock;
      uwsgi_read_timeout 1800;
      uwsgi_send_timeout 300;
    }
}

包含该配置文件

修改/etc/nginx下nginx.conf

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/order.conf;

重启nginx

service nginx start|restart

查看状态

[root@VM_0_14_centos nginx]# systemctl status nginx
● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-03-26 02:09:28 CST; 17min ago
     Docs: http://nginx.org/en/docs/
  Process: 7516 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 7517 (nginx)
   CGroup: /system.slice/nginx.service
           ├─7517 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           └─7518 nginx: worker process

nginx的权限问题(13: Permission denied)解决办法

修改nginx.conf

找到
user nobody 改成:user root 停止nginx
-s stop 重启nginx -c nginx.conf

 设置ssl安全证书

首先在腾讯云上申请证书

 

 

 

 

证书申请成功后,下载到服务器上

 

 

 

 

 

编辑order.conf增加ssl配置

        listen 443 ssl;
        server_name xx.com.cn;
        ssl on;
        #证书文件名称
        ssl_certificate  xx.cn_bundle.crt;
        #私钥文件名称
        ssl_certificate_key xx.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;

重启nginx

service nginx reload

在浏览器上输入https://xxx.com.cn 查看是否有绿色标识

 

posted @ 2020-03-26 02:47  一只小小的寄居蟹  阅读(4857)  评论(0编辑  收藏  举报