【问题标题】:Varnish Cache + Nginx + Wordpress, redirect loopVarnish Cache + Nginx + Wordpress,重定向循环
【发布时间】:2015-12-09 05:10:54
【问题描述】:

我一直在玩 Varnish,但是我遇到了一个问题,导致我的所有网站(主要是 Wordpress 和 Drupal)上出现无限重定向循环。卷曲到 localhost:8080 并将“主机”设置为标题会输出正确的 html,因此它不是 Nginx,但是当卷曲到 localhost(点击清漆)时,响应是“301 Moved Permanently”。

有什么想法吗?

这是一个站点的虚拟主机配置:

index index.php;
server {
        server_name www.example.com;
        rewrite ^ $scheme://example.com$request_uri? permanent;
}
server {
        listen   8080;
        server_name example.com;
        access_log /var/www/logs/access.log;
        error_log /var/www/logs/error.log;
        root /var/www/example.com/public_html;
        include global/restrictions.conf;

        location / {
                try_files $uri $uri/ /index.php;
                if (!-e $request_filename) {
                        rewrite ^/(.*)$ /index.php?q=$1 last;
                }
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/tmp/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
        }
}

Varnish 的配置可以在这里找到: https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl 只是我稍微修改了一下,所以端口是 8080

谢谢

【问题讨论】:

    标签: wordpress curl nginx varnish varnish-vcl


    【解决方案1】:

    我认为您也需要 listen 8080; 进入第一台服务器:

    server {
        listen   8080;
        server_name www.example.com;
        rewrite ^ $scheme://example.com$request_uri? permanent;
    }
    

    【讨论】:

    • 啊,对,这很有道理。当我有机会并回复你时,我会试试看!谢谢
    【解决方案2】:

    如果您仍在寻找可行的解决方案,您可以在最新 Plesk Onyx 版本的 Docker 容器中使用 Varnish。

    教程:https://www.plesk.com/blog/product-technology/varnish-wordpress-docker-container

    【讨论】:

      猜你喜欢
      • 2013-11-27
      • 2015-02-26
      • 2015-08-30
      • 2015-03-11
      • 2019-08-31
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      • 2019-04-23
      相关资源
      最近更新 更多