Search code examples
nginxvarnishvarnish-vcl

Nginx and Varnish only serving up welcome page


I've installed and configured Nginx and varnish on a new Ubuntu 12.04 server. After upgrading Nginx to 1.4.1, I had to update some configuration settings. Now I am only seeing the Nginx "Welcome to nginx!" page.

One note, I have to access this site via the direct IP address until we update our DNS settings to the new server, not sure if that matters.

Here are my configurations:

Nginx default, /etc/nginx/sites-available/default:

server {
    listen 81 default_server;
    listen [::]:81 default_server ipv6only=on;

    root /home/website/public_html;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    server_name 111.111.11.11; #Server IP here

Varnish default VCL, etc/varnish/default.vcl

backend default {
    .host = "127.0.0.1";
    .port = "81";
    .connect_timeout = 5s;
    .first_byte_timeout = 10s;
    .between_bytes_timeout = 10s;
}

Varnish, /etc/default/varnish

DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,1G"

Solution

  • It turns out my config was fine, I just had my FastCBI server section commented out in Nginx's default file. I uncommented the below and was all set.

    location ~ \.php$ {
        #try_files $uri =404;
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    
        # With php5-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }