nginx配置http、https访问,nginx指定ssl证书,阿里云腾讯云华为云设置nginx https安全访问
生活随笔
收集整理的這篇文章主要介紹了
nginx配置http、https访问,nginx指定ssl证书,阿里云腾讯云华为云设置nginx https安全访问
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
nginx配置http、https訪問
-
要設置https訪問需要從對應的云廠商申請證書,并下載Nginx證書到服務器。
-
我這里從阿里云申請了免費的域名證書,然后將證書放置在服務器的/etc/ssl/.com/路徑下,開始配置
這里直接上server節點,放在你的nginx.conf文件中(覆蓋也可以)
server {# http 監聽80端口listen 80 default_server;listen [::]:80 default_server;server_name _;root /usr/share/nginx/html;# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;# 域名根路徑直接訪問的路徑location / {root /opt/website/;index index.html index.htm;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}}# 設置https訪問則多添加一個server節點server{#監聽443端口listen 443;#對應的域名,把ck67.com改成自己的域名就可以了server_name ck67.com;ssl on;#從云廠商獲取到的第一個文件的全路徑ssl_certificate /etc/ssl/.com/6499202_ck67.com.pem;#從云廠商獲取到的key文件路徑ssl_certificate_key /etc/ssl/.com/6499202_ck67.com.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;#這是我的主頁訪問地址,因為使用的是靜態的html網頁,所以直接使用location就可以完成了。location / {root /opt/website/;index index.html index.htm;}}
配置好后使用 systemctl restart nginx重啟即可,直接使用https訪問一下試試吧!
總結
以上是生活随笔為你收集整理的nginx配置http、https访问,nginx指定ssl证书,阿里云腾讯云华为云设置nginx https安全访问的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里云K8S容器服务的使用
- 下一篇: 使用hello word写小说