Score:0

how to configure Varnish, Nginx Virtual Host & Letsencrypt SSL together

eg flag

I need some help in configuration of Varnish Cache, Nginx, & SSL on virtual hosts. I am able to configure the Varnish & Nginx on the server IP (Default virtual host). When I access site at http I am able to see curl -I http://example.com enter image description here

But when use same domain with SSL ( curl -I https://example.xom ) I get this

enter image description here

Can someone guide me what are the steps to configure SSL on Varnish Cache?

Score:0
au flag

If you're already using Nginx to handle TLS traffic, you might as well configure a TLS virtual host in Nginx that proxies traffic to Varnish.

Here's an example configuration in Nginx:

server {

    listen 443 ssl http2;
    server_name example.com www.example.com;

    ssl_certificate /path/to/cert/cert.pem;
    ssl_certificate_key /path/to/key/key.pem;
    ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_session_cache    shared:SSL:10m;
    ssl_session_timeout 24h;
    keepalive_timeout 300s;

    location / {
        proxy_pass http://127.0.0.1;
        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_set_header X-Forwarded-Proto $scheme;

    }

}

You can merge it with your existing TLS config for Nginx. Just ensure that you're proxying the content to Varnish via proxy_pass instead of just serving content locally.

In this case you'll use Nginx as a TLS proxy, not as a web server.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.