ssl - 我怎样才能告诉 Varnish 发送 https 给主人?

标签 ssl nginx load-balancing varnish

我有几个 NGINX 服务器在负载均衡器后面运行。

我如何告诉 Varnish 通过 https 将任何域上的所有传入请求发送到 10.x.x.x:443 (master_ip:443)?我们在中央系统上处理大量网站,因此需要某种模式。

最佳答案

尝试将此重定向作为起点并自定义您的多站点设置:

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);
    }

引用自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 发送 https 给主人?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19075997/

相关文章:

node.js - Socket.io 自过去 1 周以来已停止工作

node.js - 快速路由在本地计算机上按预期运行。但在 Nginx 上则不然

linux - nginx 配置 - 动态路由到根路径

node.js - 如何在两个docker服务之间实现负载均衡?

load-balancing - 缺少 Google 云负载平衡器自定义 http header

wordpress - 如何为我的 wordpress 网站创建一个真实的 ssl

java - Google App Engine 和 HTTPS 策略

apache - htaccess 阻止在 chrome 中使用全局 SSL 重定向

java - 如何同时使用具有加密(ssl)和xinetd的JRMP(RMI)?

docker - Google Container Engine 上的跨区域负载均衡 + 路由