Apache returns error 403 from varnish

Avatar
  • Answered
Varnish is installed properly and seems to work fine on the same machine with apache. It passes content from backend but caching doesnt work. Website is custom coded. 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. /etc/varnish/default.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.conf 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 suPHP_UserGroup vps vps SuexecUserGroup vps vps RMode config RUidGid vps vps # 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 host is configured with the same IP xxx.xxx.xxx.xxx:8080. And don't know where else to look. Any help is appreciated. Thank you derek
Avatar
johnpaulb-imhs1
Hello derek,

Thank you for your question regarding . Check your varnish configuration first, to ensure it is setup correctly.

We are happy to help you troubleshoot further, but will need some additional information. What version of Varnish did you install? Sometimes cPanel has limitations on the versions it will allow. We have installed varnish 3 on a VPS and it's working no issues.

Thank you,
John-Paul