本文介绍了使用Varnish + Nginx(HTTPS)时重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试使用HTTPS在WP站点中使用Varnish和Nginx。

I am trying to use Varnish and Nginx in a WP site using HTTPS.

一切都适用于缓存文件但是当Varnish发现它不应该缓存的东西,它将它发送回Nginx。
此时,Nginx再次向Varnish发送HTTPS请求,导致无限循环。

Everything is working fine with cached files but when Varnish discover something it shouldn't cache, it sends it back to Nginx.At this point, Nginx is sending the HTTPS request to Varnish again causing the infinite loop.

我尝试了很多东西并通过互联网搜索很多但到目前为止没有任何工作。

I have tried a lot of things and searched over the Internet a lot but nothing has worked so far.

这是Varnish送回的一个例子:

This is an example of something Varnish is sending back:

if (req.url ~ "/wp-(login|admin|cron)") {
        # Don't cache, pass to backend
        return (pass);
}

这是处理433的Nginx位置块:

And this is the Nginx location block which deals with 433:

location / {
    # Send request to varnish
    proxy_pass  http://127.0.0.1:8888;
    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 $scheme;
    proxy_set_header X-Forwarded-Port 443;
    proxy_set_header Host $host;
}

我想Varnish正在发送返回(传递)将数据传回Nginx,但我现在不知道如何使用其他位置块渲染数据。

I guess that Varnish is sending with the return(pass) the data back to Nginx, but I don't now how to render that data using another location block.

我怎样才能抓住在Nginx中来自Varnish的请求,并区分来自常规433端口的请求?

How can I catch in Nginx the request which is coming from Varnish and distinguish between that and the requests which are coming from the regular 433 port?

提前致谢!

推荐答案

这可能是因为hhvm期望通过端口443(https)的请求导致重定向到https,最终再次以清漆结束。

This might have been caused by hhvm expecting the request over port 443(https) resulting in a redirect to https that ends up in varnish again.

这篇关于使用Varnish + Nginx(HTTPS)时重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 04:31