Nginx配置开启HTTPS

  1. 获取证书文件

  2. Nginx 开启SSL

    server {
    listen 443 default ssl;
    server_name localhost;
    #charset koi8-r;
    #access_log logs/host.access.log main;
    proxy_set_header Host $host;

    复制代码
         ssl_certificate /usr/local/nginx/cert/server.pem;
         ssl_certificate_key /usr/local/nginx/cert/ca.key;
         ssl_session_cache   shared:SSL:128m;
         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   html;
             index  index.html index.htm;
             try_files $uri /index.html;
         }
         # redirect server error pages to the static page /50x.html
         #
         error_page   500 502 503 504  /50x.html;
         location = /50x.html {
             root   html;
         }
    
     }
  3. 重启Nginx

bash 复制代码
cd ../sbin
./nginx -s reload
相关推荐
我才是鳴海步12 分钟前
基于docker技术的单主机环境模拟测试批量客户端
运维·docker·容器
conkl1 小时前
Apache网页优化实战指南 - 让网站加载速度提升
linux·运维·服务器·开发语言·阿里云·apache
thinkMoreAndDoMore2 小时前
linux驱动开发(9)- 信号量
linux·运维·驱动开发
海天胜景2 小时前
nginx 配置返回 文件大小
运维·nginx
五阿哥爱跳舞3 小时前
【环境配置】解决linux每次打开终端都需要source .bashrc文件的问题
linux·运维·服务器
时央1234563 小时前
C#使用Tuple方法实现OpreateResultModel功能
运维·开发语言·c#
爱学习的白杨树3 小时前
Spring Cloud Gateway 介绍
java·运维·开发语言
网易独家音乐人Mike Zhou3 小时前
【Linux应用】Linux系统日志上报服务,以及thttpd的配置、发送函数
linux·运维·服务器·mcu·物联网·嵌入式·iot
一眼万年044 小时前
NGINX 高并发 HTTP 处理深度解析
nginx·微服务
bingbingyihao4 小时前
服务自动添加实例工具
linux·运维·bash