分类
Magento 服务器

magento2 – varnish cache in ubuntu

安装

apt-get install varnish   //安装
service varnish status   /查看状态
varnishd -V    //查看版本

开启8080端口配置方法

#服务器配置
server {
    listen 8080;
    server_name aidot.nick-xia.com;
    index index.php index.html index.htm default.php default.htm default.html;
    set $MAGE_ROOT /www/wwwroot/aidot.nick-xia.com;
    include /www/wwwroot/aidot.nick-xia.com/nginx.conf.sample;
    access_log /www/wwwlogs/aidot.nick-xia.com.log;
    error_log /www/wwwlogs/aidot.nick-xia.com.error.log;
}
#重定向到https
server {
    listen 80;
    server_name aidot.nick-xia.com;
    return 301 https://aidot.nick-xia.com/$request_uri;
}

#https配置和varnish配置
server
{
     listen 443 ssl http2;
    server_name aidot.nick-xia.com;

    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    ssl_certificate    /www/server/panel/vhost/cert/aidot.nick-xia.com/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/aidot.nick-xia.com/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    
    location / {
        proxy_pass http://127.0.0.1:6081;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Ssl-Offloaded "1";
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-Port 443;
        proxy_redirect  http://aidot.nick-xia.com:8080/  /;
        proxy_http_version 1.1;
    }
}