Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fancy&customized URL support for awstats with Nginx. Access through http://example.com/awstats/
server {
listen 127.0.0.1:81;
server_name _;
access_log /var/log/nginx/awstats.access_log combined;
error_log /var/log/nginx/awstats.error_log;
root /usr/share/awstats/wwwroot;
index /awstats.pl;
location ~ \.pl$ {
rewrite ^((?!cgi-bin).)(.*)$ /cgi-bin/$2 break;
gzip off;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
#fastcgi_index /cgi-bin/awstats.pl;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param SERVER_NAME $host;
}
# Restrict access
auth_basic "Restricted";
auth_basic_user_file /etc/awstats/htpasswd;
# Static file handled by nginx automatically
# default config not useful any more
}
server {
server_name your.domain;
listen 80;
access_log /var/log/nginx/vhost.access_log;
error_log /var/log/nginx/vhost.error_log;
root /your/wwwroot/path;
# ... other configs
location /awstats/ {
rewrite ^/awstats(/.*)$ $1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header HTTP_AUTHORIZATION $http_authorization;
proxy_pass http://127.0.0.1:81;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.