Last active
August 31, 2021 22:44
-
-
Save ttimasdf/c8e4459bc944fad352178649337c217f to your computer and use it in GitHub Desktop.
Fancy&customized URL support for awstats with Nginx. Access through http://example.com/awstats/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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