Nginx

使用 Nginx SSL 終止的清漆記憶體

  • August 22, 2019

如何將清漆記憶體與 nginx SSL 終止一起用於我的僅限 SSL(僅限 Https)網站?我使用 ubuntu 18.04,我目前正在我的伺服器上執行一個 wordpress 站點。

到目前為止,我添加了完整的方式

mkdir /var/cache/nginx/cache

chown nginx:nginx /var/cache/nginx/cache

現在編輯 http 部分下方的 nginx.conf

###New cache settings as default
proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=hd_cache:10m max_size=10g inactive=2d use_temp_path=off;
proxy_cache_methods GET HEAD POST;
proxy_cache_valid 200 302 3d;
proxy_cache_valid 404      1m;

編輯 /etc/nginx/sites-avaible/yoursite.com

#http to https redirect
server {
       server_name yoursite.com *.yoursite.com;
       listen 80;
       return 301 https://$host$request_uri;
}

#https server
server {
       proxy_read_timeout 3600;
       listen 443 ssl http2;
       server_name yoursite.com *.yoursite.com;

#a special location in case don't cache this file can be deleted
location updater/serversettings.xml {
         expires -1;
         add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
       }

               #The root/rest will be redirected
               location / {
                       proxy_cache             hd_cache;
                       proxy_set_header        X-Cache-Status $upstream_cache_status;
                       proxy_cache_valid       200 1w;
                       proxy_pass              https://10.10.200.4;
                       proxy_set_header        Host $http_host;
                       proxy_buffers           16 8m;
                       proxy_buffer_size       2m;
                       gzip on;
                       gzip_vary          on;
                       gzip_comp_level    9;
                       gzip_proxied       any;
}
   #SSL Cert section, as we require ssl, using certbot LetsEncrypt
   ssl_certificate /etc/letsencrypt/live/yoursite.com-0001/fullchain.pem; # managed by Certbot
   ssl_certificate_key /etc/letsencrypt/live/yoursite.com-0001/privkey.pem; # managed by Certbot
}

現在啟用此站點。

ln -s /etc/nginx/sites-avaible/yoursite.com /etc/nginx/sites-enabled/yoursite.com

並執行

服務 Nginx 重新載入

此設置適用於 WordPress 網站,我遇到的頁面速度計數器為 95+

引用自:https://serverfault.com/questions/980184