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
相关推荐
特长腿特长6 小时前
centos、ubantu系列机的用户和用户组的结构是什么?具体怎么配置?用户组权限怎么使用?这篇文章持续更新,帮助你复习linux的基础知识
linux·运维·centos
zzzyyy5386 小时前
Linux环境变量
linux·运维·服务器
赛博云推-Twitter热门霸屏工具7 小时前
Twitter运营完整流程:从0到引流获客全流程拆解(2026)
运维·安全·自动化·媒体·twitter
CHHC18807 小时前
NetCore树莓派桌面应用程序
linux·运维·服务器
帮我吧智能服务平台8 小时前
装备制造智能制造升级:远程运维与智能服务如何保障产线OEE
运维·服务器·制造
w6100104668 小时前
cka-2026-cri-dockerd
运维·k8s·cka
卤炖阑尾炎9 小时前
PostgreSQL 日常运维全指南:从基础操作到备份恢复
运维·数据库·postgresql
handsomestWei10 小时前
Docker引擎API接入配置
运维·http·docker·容器·api
Tingjct10 小时前
Linux常用指令
linux·运维·服务器
daad77710 小时前
wifi_note
运维·服务器·数据库