ngxin http https 配置

nginx版本:nginx/1.16.1

需要注意两点
1 有的版本 443server要在80前面
2 有的端口监听需要加ssl

listen 443 ssl;
listen 443;

CenterOS 服务器拷贝下来的示例:

user  root root;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    server {
      listen 443 ssl;
      server_name  www.elgratia.com elgratia.com;
      root /root/kb/feedback/web;
      #access_log  logs/nginx.access.log  main;
      ssl_certificate /root/https/www.elgratia.com_chain.crt;
      ssl_certificate_key /root/https/www.elgratia.com_key.key;
      ssl_session_timeout 5m;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
      ssl_prefer_server_ciphers on;
      location / {
        root /root/kb/feedback/web;
        index index.html;
      }
      location ^~ /api{
        proxy_pass http://156.232.6.221:3900/api;
      }

    }
    server {
      listen 80;
      server_name  www.elgratia.com elgratia.com;
      index  index.html index.htm;
      root   /root/kb/feedback/web;
      client_max_body_size   15M;
      location / {
        #root   /root/kb/feedback/web;
        #proxy_pass http://156.232.6.221:80;
        index  index.html index.htm;
        try_files $uri $uri/ @router;
      }
      location ^~ /api {
        proxy_pass http://156.232.6.221:3900/api;
      }
      location @router {
        rewrite ^.*$ /index.html last;
      }
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
        root   html;
      }
    }
    #gzip  on;
    #include /etc/nginx/vhosts/*;
    # include /etc/nginx/conf.d/*.conf;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值