nginx 1.18配置ssl問題


把一個NETCORE網站部署到NGINX上,按微軟官方文檔弄好了 https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.1

想配置SSL的HTTPS證書,騰訊雲上申請了免費的,之前在WIN+IIS 配置是成功的,按網上的弄好了,我的用的是寶塔的NGINX,可以在網頁上建立網站了改NGINX配置文件就行了,

配置好后重啟NGINX了,結果不行的,搜索一翻,原來是centos服務器自帶的firewall防火牆的問題,https://www.jianshu.com/p/17b73ad6a4b8, xshel上運行以下命令就行了



firewall-cmd --zone=public --add-port=443/tcp --permanent  增加443端口

firewall-cmd --reload  重啟防火牆



或者直接就把防火牆停掉


systemctl stop firewalld


其他備注:

在xshell 里登錄LINUX服務器后,輸入BT命令,可以查看寶塔默認的安裝信息



以下是我的nginx配置文件:

 

 server {
listen 80;
server_name tudi.niunan.net;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
} 
server {
     #SSL 訪問端口號為 443
     listen 443 ssl; 
     #填寫綁定證書的域名
     server_name tudi.niunan.net;
     #證書文件名稱
     ssl_certificate /www/server/nginx/conf/1_tudi.niunan.net_bundle.crt; 
     #私鑰文件名稱
     ssl_certificate_key /www/server/nginx/conf/2_tudi.niunan.net.key; 
     ssl_session_timeout 5m;
     #請按照以下協議配置
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
     #請按照以下套件配置,配置加密套件,寫法遵循 openssl 標准。
     ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; 
     ssl_prefer_server_ciphers on;
     location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

     }
 }



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM