HTTPS協議安裝

記錄一下nginx的https證書配置內容,可能並不通用,僅作參考:html

server {
  listen 443;   #指定ssl監聽端口
  server_name localhost;  #服務器域名

  ssl on;
  root html;
  index index.html index.htm;
  ssl_certificate      cert/cc.pem;    #指定服務器證書路徑
  ssl_certificate_key  cert/cc.key;    #指定私鑰證書路徑
  ssl_session_cache    shared:SSL:10m; #SSL會話緩存10MB
  ssl_session_timeout 5m;
  ssl_protocols  SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_prefer_server_ciphers on;

 location = /f5check.html {
    proxy_pass http://nginxs;
    root html; 
 } 

  location /clientdata {
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_pass http://nginxs;
  }

  location /eventlog {
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_pass http://nginxs;
  }

  location /usinglog {
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_pass http://nginxs;
  }

  location /errorlog {
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_pass http://nginxs;
  }

  location /appinfo {
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_pass http://nginxs;
  }
  location / {
     root   html;
     index  index.html index.htm;
  }
}

須要注意的是,我這邊使用了非線上頒發的證書,弄了好久都沒有完成。後來使用了線上的證書以後,經過當前的配置就能夠解決這個https訪問的問題。
須要修改的地方主要是證書的位置,其餘的依據需求進行修改便可。nginx

相關文章
相關標籤/搜索