Varnish is installed properly and seems to work fine on the same machine with apache. It passes content from backend but caching doesnt work.

Header looks like below:

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

log from /usr/local/apache/domlogs/domain.com

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

apache error_log

[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

where xxx.xxx.xxx.xxx is public IP of my vps where both apache and varnisch are installed.


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


<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 webmaster@coke.domain.com
    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 !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup vps vps
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid vps vps
    <IfModule itk.c>
        # For more information on MPM ITK, please read:
        #   http://mpm-itk.sesse.net/
        AssignUserID vps vps

    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"

Apache/2.2.31 port 8080
varnish-4.1.2 revision 0d7404e port 80
SELinux is disabled

Mod_Security doesn't list any errors

I'm sending requests to xxx.xxx.xxx.xxx:8080, which the apache is listening on and my virtual hosts are configured with the same IP xxx.xxx.xxx.xxx:8080.

And don't know where else to look.

Any help is appreciated. Thank you d.

  • access directly to ip:8080 also reported 403 error? which user is apache running on? can you update your question by ls -l /home/vps/public_html to see current permissions? – cuongnv23 May 20 '16 at 4:06


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

Mostly in httpd.conf/apache.conf the access is restricted.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.