wordpress - 使用Varnish + Nginx(HTTPS)时的重定向循环

标签 wordpress loops nginx https varnish

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

缓存文件一切正常,但是当 Varnish 发现不应该缓存的内容时,它会将其发送回 Nginx。
此时,Nginx 再次向 Varnish 发送 HTTPS 请求,导致死循环。

我尝试了很多东西并在互联网上搜索了很多,但到目前为止没有任何效果。

这是 Varnish 发回的示例:

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

这是处理 433 的 Nginx 位置块:
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 正在使用 return(pass) 将数据发送回 Nginx,但我现在不知道如何使用另一个位置块呈现该数据。

如何在 Nginx 中捕获来自 Varnish 的请求并区分该请求和来自常规 433 端口的请求?

提前致谢!

最佳答案

我发现了问题: HHVM

我在Nginx(端口9433)上创建了另一个没有HHVM的后端,并在Varnish中执行了以下操作:

backend no_hhvm {
   .host = "127.0.0.1";
   .port = "9433";
}

然后...
# Either the admin pages or the login
if (req.url ~ "/wp-(login|admin|cron)") {
        # Don't cache, pass to backend
        set req.backend = no_hhvm;
        return (pass);
}

因此,当不缓存该页面时,它将转到不使用HHVM的端口9433。

现在工作很好。

关于wordpress - 使用Varnish + Nginx(HTTPS)时的重定向循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27929163/

相关文章:

nginx - http2模块nginx不工作

mysql - Wordpress 自定义 SQL 以获取具有给定元值的三个帖子

css - 为每行设置最大宽度或在 CSS 中的一段文本中插入换行符

javascript - 普通 JS : make 80% width element 100% IF contains an image

c++ - 如果没有在foreach循环中写 '&',为什么会出错?

linux - 为什么遍历一组 linux 文件即使没有匹配项也总是返回 1?

wordpress - 为什么我只在 Firefox 上看到奇怪的代码?

c++ - 循环 - 访问冲突写入位置 0xabababab

nginx - 为什么 wiki.js 安装时需要公共(public) URL?

python - 如何使用unix套接字将url参数传递给Nginx proxy_pass后面的Flask