Apache 从 Varnish 返回错误 403

Apache 从 Varnish 返回错误 403

Varnish 安装正确,似乎在装有 apache 的同一台机器上工作正常。它从后端传递内容,但缓存不起作用。

标头如下所示:

HTTP/1.1 403 Forbidden => 
Date => Thu, 19 May 2016 05:10:10 GMT
Server => Apache
Vary => Accept-Encoding
Content-Type => text/html; charset=iso-8859-1
X-Varnish => 218
Age => 0
Via => 1.1 varnish-v4
Connection => close

来自 /usr/local/apache/domlogs/domain.com 的日志

xxx.xxx.xxx.xxx - - [19/May/2016:00:31:23 -0400] "GET / HTTP/1.1" 403 

Apache 错误日志

[Thu May 19 00:54:45 2016] [error] [client xxx.xxx.xxx.xxx] client denied by server configuration: /home/vps/public_html/domain.com/
[Thu May 19 00:54:45 2016] [error] [client xxx.xxx.xxx.xxx] client denied by server configuration: /home/vps/public_html/domain.com/page-not-found

其中 xxx.xxx.xxx.xxx 是安装了 apache 和 varnisch 的 vps 的公网 IP。

/etc/varnish/默认.vcl

vcl 4.0;

import std;
import directors;

backend default {
    .host = "xxx.xxx.xxx.xxx"; (my public IP)
    .port = "8080";
}

sub vcl_recv {
#    IP forwarding.
     if (req.restarts == 0) {
         if (req.http.x-forwarded-for) {
          set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
          } else {
          set req.http.X-Forwarded-For = client.ip;
          }
     }


#   send all traffic to the default backend
    set req.backend_hint = default;

    if (req.method != "GET" &&
      req.method != "HEAD" &&
      req.method != "PUT" &&
      req.method != "POST" &&
      req.method != "TRACE" &&
      req.method != "OPTIONS" &&
      req.method != "PATCH" &&
      req.method != "DELETE") {
      return (pipe);
    }

    if (req.method != "GET" && req.method != "HEAD") {
                return (pass);
    }

    if (req.http.Authorization || req.http.Cookie) {
               return (pass);
    }


    return (hash);
}

httpd配置文件

<VirtualHost xxx.xxx.xxx.xxx:8080>
    ServerName coke.domain.com
    ServerAlias www.coke.domain.com domain.co.ke www.domain.co.ke
    DocumentRoot /home/vps/public_html/domain.co.ke
    ServerAdmin [email protected]
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/coke.domain.com combined
    CustomLog /usr/local/apache/domlogs/coke.domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User vps # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup vps vps
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup vps vps
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid vps vps
    </IfModule>
    <IfModule itk.c>
        # For more information on MPM ITK, please read:
        #   http://mpm-itk.sesse.net/
        AssignUserID vps vps
    </IfModule>

    ScriptAlias /cgi-bin/ /home/vps/public_html/domain.co.ke/cgi-bin/
    Include "/usr/local/apache/conf/userdata/std/2_2/vps/coke.domain.com/*.conf"
</VirtualHost>

Apache/2.2.31 端口 8080
varnish-4.1.2 修订版 0d7404e 端口 80
SELinux 已禁用

Mod_Security 没有列出任何错误

我正在向 xxx.xxx.xxx.xxx:8080 发送请求,apache 正在监听该请求,并且我的虚拟主机配置了相同的 IP xxx.xxx.xxx.xxx:8080。

而且不知道还能去哪儿找。

任何帮助都值得感激。谢谢 d。

答案1

尝试

<Directory "/home/vps/public_html/domain.co.ke">
    Order Allow,Deny
    Allow from all
    # or
    # Allow from 127.0.0.1
</Directory>

主要是在httpd.conf/apache.conf中访问受到限制。

相关内容