1.官方源安装varnish
apt-get install apt-transport-https curl https://repo.varnish-cache.org/GPG-key.txt | apt-key add - echo "deb https://repo.varnish-cache.org/ubuntu/ trusty varnish-4.1" \ >> /etc/apt/sources.list.d/varnish-cache.list apt-get update apt-get install varnish
2.修改varnish默认端口
sudo vi /etc/default/varnish
3.安装nginx
sudo apt-get install nginx
4.配置反向代理配置
server { listen 443 ssl; server_name example.com; ssl_certificate /etc/nginx/ssl/nginx.crt; ssl_certificate_key /etc/nginx/ssl/nginx.key; location / { proxy_pass http://127.0.0.1:80; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; proxy_set_header Host $host; } }
sudo service nginx restart