Ruok2bu - 2014-01-14

I have awstats set up and working with Nginx and perl but all images return a 404 error. The virtual host config is identical to other websites where images work fine except for the added part for perl.

I think i know what's happening but i dont know how to fix it; images are being sent to the perl interpreter instead of Nginx. Here's my config:

server {
listen 1.2.3.4:80;
server_name stats.example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}

server {
listen 1.2.3.4:443;
server_name stats.example.com;

access_log /path/to/logs/stats/access.log;

    error_log  /path/to/logs/stats/error.log;

    index awstats.pl index.html index.htm;
    client_max_body_size 40M;

    ssl on;
    ssl_certificate /etc/nginx/ssl/ssl.crt;
    ssl_certificate_key /etc/nginx/ssl/private.key;

    location / {
    root   /path/to/the/awstats/wwwr;
    index  index.html index.htm;
    try_files $uri $uri/ /index.html?$uri&$args;
    auth_basic            "Restricted";
    auth_basic_user_file   /path/to/the/awstats/htpasswd;
    }

    # Block Image Hotlinking
    location /icon/ {
    valid_referers none blocked stats.example.com;
    if ($invalid_referer) {
    return   403;
    }
    }

    # Dynamic stats.
    location ~ \.pl$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  127.0.0.1:8999;
    fastcgi_index index.pl;
    fastcgi_param  SCRIPT_FILENAME  /path/to/the/awstats/wwwroot/$fastcgi_script_name;
    }

}