1

I have a couple NGINX servers running behind a load balancer.

How can I tell varnish to send all incoming requests on any domain over https to 10.x.x.x:443 (master_ip:443)? We handle lots of sites on a central system so a pattern of some sort would be needed.

4

1 回答 1

3

Try this redirect as a starting point and customize to your multi-site setup:

sub vcl_recv {
    if ( (req.http.host ~ "^(?i)somesite.org" || req.http.host ~ "^(?i)www.somesite.org")
         && req.http.X-Forwarded-Proto !~ "(?i)https") {
        set req.http.x-Redir-Url = "https://www.somesite.org" + req.url;
        error 750 req.http.x-Redir-Url;
    }
}

sub vcl_error {
    if (obj.status == 750) {
        set obj.http.Location = obj.response;
        set obj.status = 302;
        return (deliver);
    }

Referenced from this link:

Useful when you want to redirect the clients to an SSL-version of your site, given that your varnish instance is running behind some SSL-termination point, such as a nginx instance with SSL enabled.

于 2013-09-29T08:37:03.857 回答