简体   繁体   English

如何告诉清漆将https发送给master?

[英]How can I tell varnish to send https to master?

I have a couple NGINX servers running behind a load balancer. 我有几个NGINX服务器在负载均衡器后面运行。

How can I tell varnish to send all incoming requests on any domain over https to 10.xxx:443 (master_ip:443)? 如何告诉varnish通过https将所有传入请求发送到10.xxx:443(master_ip:443)? We handle lots of sites on a central system so a pattern of some sort would be needed. 我们在中央系统上处理许多站点,因此需要某种模式。

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. 在您希望将客户端重定向到站点的SSL版本时很有用,因为您的varnish实例正在某些SSL终止点后面运行,例如启用了SSL的nginx实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM