溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

nginx 代理80端口轉(zhuǎn)443端口的實(shí)現(xiàn)

發(fā)布時(shí)間:2020-10-24 09:06:46 來源:腳本之家 閱讀:204 作者:詩(shī)水人間 欄目:開發(fā)技術(shù)

nginx.conf配置文件如下

user nginx;
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;
  #tcp_nopush   on;

  keepalive_timeout 65;

  #gzip on;

  include /etc/nginx/conf.d/*.conf;
 
 # 以下屬性中以ssl開頭的屬性代表與證書配置有關(guān),其他屬性請(qǐng)根據(jù)自己的需要進(jìn)行配置。
 server {
 listen 443 ssl;  #SSL協(xié)議訪問端口號(hào)為443。此處如未添加ssl,可能會(huì)造成Nginx無法啟動(dòng)。
 server_name localhost; #將localhost修改為您證書綁定的域名,例如:www.example.com。
 root html;
 index index.html index.htm;
 ssl_certificate /etc/nginx/huashengshu.top.pem;  #替換成您證書的文件名。
 ssl_certificate_key /etc/nginx/huashengshu.top.key;  #替換成您證書的密鑰文件名。
 ssl_session_timeout 5m;
 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  #使用該協(xié)議進(jìn)行配置。
 ssl_prefer_server_ciphers on;  
 location / {
  root /etc/nginx/hss;  #站點(diǎn)目錄。
  index index.html index.htm;  
 }
 }
 

 server {
 listen 80;
 server_name huashengshu.top;
 rewrite ^(.*)$ https://${server_name}$1 permanent; 
 }

}

起作用的是

 server {
 listen 80;
 server_name huashengshu.top;
 rewrite ^(.*)$ https://${server_name}$1 permanent; 
 }

到此這篇關(guān)于nginx 代理80端口轉(zhuǎn)443端口的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)nginx 代理80轉(zhuǎn)443內(nèi)容請(qǐng)搜索億速云以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持億速云!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI