I've been playing around with Varnish however I've encountered an issue that causes an infinite redirect loop on all my sites (Wordpress and Drupal mainly). Curl to localhost:8080 and setting the "Host" as a header outputs the correct html so it's not Nginx, however when curling to localhost (hitting varnish) the response is "301 Moved Permanently".
Any ideas?
Here's a vhost config for a site:
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;
}
}
And the config for Varnish can be found here: https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl except I've modified it slightly so the port is looking at 8080
Thanks