Welcome! Log In Create A New Profile

Advanced

Rewriteing awstats to base path

Moritz Herrmann
January 01, 2014 11:44AM
Hi,

I like to beautify my urls used for awstats.

Currently I have to use the following path for awstats
> /cgi-bin/awstats.pl?config=www.example.com
that works as expected.

For easier handling for our users I like to shorten the url to /www.example.com
I tried a simple rewrite like
> rewrite ^/www.example.com$ /cgi-bin/awstats.pl?config=www.example.com;

but I'll get the following error
> 2013/12/31 23:43:20 [error] 23736#0: *1 open() "/srv/awstats/dist/wwwroot/awstats.pl" failed (2: No such file or directory), client: ::ff:123.123.123.123, server: awstats.example.com, request: "GET /awstats.pl?config=www.example.com&framename=mainleft HTTP/1.1", host: "awstats.example.com", referrer: "http://awstats.example.com/www.example.com"

here is the full server block
> server {
> listen [::]:80;
> server_name awstats.example.com awstats7.example.com;
>
> root /srv/awstats/dist/wwwroot;
>
> auth_basic "Restricted";
> auth_basic_user_file /srv/awstats/.htpasswd;
>
> location ~ ^/cgi-bin/awstats\.pl {
> include fastcgi_params;
> fastcgi_pass unix:/var/run/php5-fpm.sock;
> fastcgi_param SCRIPT_FILENAME /srv/awstats/dist/tools/nginx/awstats-fcgi.php;
> fastcgi_param X_SCRIPT_FILENAME $document_root$fastcgi_script_name;
> fastcgi_param X_SCRIPT_NAME $fastcgi_script_name;
> }
>
> rewrite ^/awstats/(.*)$ /cgi-bin/$1;
> rewrite ^/www.example.com$ /cgi-bin/awstats.pl?config=www.example.com;
>
> location = /robots.txt { return 200 "User-agent: *\nDisallow: /\n"; }
> }

Desired url http://awstats.example.com/www.example.com

Probably I didn't fully understand the rewrite rules.

Hopefully you can help!

Best regards
moe

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rewriteing awstats to base path

Moritz Herrmann January 01, 2014 11:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 267
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready