OK Guys its long but here is the script that we used essentially to do the awstats thingy. Authentication has been done with htaccess, though... As mentioned, this was done before we knew ispCP and I think your template based mechanism is smarter... still this is all I can provide
. Some paths are different than in a ispCP setup but that should be pretty easy to change.
Below the script I included the webserver config (the part that should be included in the 00_master.conf in case of ispCP) and in the part of the vhost creation you see the recirect to this address.
Furthermore on my ispcp server I created a 00_master_ssl.conf and placed a redirect to the https site to anything coming from port 80 in the master.conf to force users to use ssl (they don't do it if you don't force them its awful). I included this also for convenience:
(if I forgot to delete any sensitive information, please do so, thanks
).
###### SCRIPT START #####
#!/bin/sh
KDNNAME=$1 #customername
DOMAINNAME=$2 #domainname
PFADVHOST=/etc/apache2/sites-available/$KDNNAME/$DOMAINNAME.conf #path of vhost
IPADRESSE=XXX.XXX.XXX.XXX
PFADAWSTATS=/etc/awstats/awstats.$DOMAINNAME.conf #path of awstats config
HOMEDIR=/home/customers
SERVERNAME=example.com
## create vhost
mkdir -p /etc/apache2/sites-available/$KDNNAME
mkdir -p $HOMEDIR/"$KDNNAME"/htdocs/"$DOMAINNAME"/cgi-bin
echo '<VirtualHost *:80>' > $PFADVHOST
echo ' ServerAdmin webmaster@'$DOMAINNAME >> $PFADVHOST
echo ' ServerName '$DOMAINNAME >> $PFADVHOST
echo ' RewriteEngine on' >> $PFADVHOST
echo ' RewriteRule ^/stats/$ https://$SERVERNAME/awstats/cgi-bin/awstats.pl?config='$DOMAINNAME' [R]' >> $PFADVHOST
echo ' RewriteRule ^/stats$ https://$SERVERNAME/awstats/cgi-bin/awstats.pl?config='$DOMAINNAME' [R]' >> $PFADVHOST
echo ' DocumentRoot /home/customers/'$KDNNAME'/htdocs/'$DOMAINNAME >> $PFADVHOST
echo ' ErrorLog /home/customers/'$KDNNAME'/logs/'$DOMAINNAME'-error.log' >> $PFADVHOST
echo ' LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined' >> $PFADVHOST
echo ' CustomLog /home/customers/'$KDNNAME'/logs/'$DOMAINNAME'-access.log combined' >> $PFADVHOST
echo ' <Directory /home/customers/'$KDNNAME'/htdocs/'$DOMAINNAME'>' >> $PFADVHOST
echo ' AllowOverride All' >> $PFADVHOST
echo ' </Directory>' >> $PFADVHOST
echo ' <Directory /home/customers/'$KDNNAME'/htdocs/'$DOMAINNAME'/cgi-bin>' >> $PFADVHOST
echo ' AllowOverride All' >> $PFADVHOST
echo ' Options +ExecCGI' >> $PFADVHOST
echo ' </Directory>' >> $PFADVHOST
echo '</VirtualHost>' >> $PFADVHOST
ln -s /etc/apache2/sites-available/$KDNNAME/$DOMAINNAME.conf /etc/apache2/sites-enabled/$DOMAINNAME.conf
# create awstats config file
echo 'LogFile="/home/customers/'$KDNNAME'/logs/'$DOMAINNAME'-access.log"' > $PFADAWSTATS
echo LogType=W >> $PFADAWSTATS
echo LogFormat=1 >> $PFADAWSTATS
echo 'LogSeparator=" "' >> $PFADAWSTATS
echo 'SiteDomain="'$DOMAINNAME'"' >> $PFADAWSTATS
echo 'HostAliases="localhost 127.0.0.1 REGEX[myserver\.com$]"' >> $PFADAWSTATS
echo DNSLookup=1 >> $PFADAWSTATS
echo 'DirData="/home/customers/'$KDNNAME'/awstats"' >> $PFADAWSTATS
echo 'DirCgi="/awstats/cgi-bin"' >> $PFADAWSTATS
echo 'DirIcons="/awstats/icon"' >> $PFADAWSTATS
echo AllowToUpdateStatsFromBrowser=0 >> $PFADAWSTATS
echo AllowFullYearView=3 >> $PFADAWSTATS
echo EnableLockForUpdate=0 >> $PFADAWSTATS
echo 'DNSStaticCacheFile="dnscache.'$DOMAINNAME'.txt"' >> $PFADAWSTATS
echo 'DNSLastUpdateCacheFile="dnscachelastupdate.'$DOMAINNAME'.txt"' >> $PFADAWSTATS
echo 'SkipDNSLookupFor=""' >> $PFADAWSTATS
echo 'AllowAccessFromWebToAuthenticatedUsersOnly=1' >> $PFADAWSTATS
echo 'AllowAccessFromWebToFollowingAuthenticatedUsers="SOME_SUPERUSER '$1'"' >> $PFADAWSTATS
echo 'AllowAccessFromWebToFollowingIPAddresses=""' >> $PFADAWSTATS
echo CreateDirDataIfNotExists=1 >> $PFADAWSTATS
echo BuildHistoryFormat=text >> $PFADAWSTATS
echo BuildReportFormat=html >> $PFADAWSTATS
echo SaveDatabaseFilesWithPermissionsForEveryone=1 >> $PFADAWSTATS
echo PurgeLogFile=0 >> $PFADAWSTATS
echo ArchiveLogRecords=0 >> $PFADAWSTATS
echo KeepBackupOfHistoricFiles=0 >> $PFADAWSTATS
echo 'DefaultFile="index.html"' >> $PFADAWSTATS
echo 'SkipHosts=""' >> $PFADAWSTATS
echo 'SkipUserAgents=""' >> $PFADAWSTATS
echo 'SkipFiles=""' >> $PFADAWSTATS
echo 'OnlyHosts=""' >> $PFADAWSTATS
echo 'OnlyUserAgents=""' >> $PFADAWSTATS
echo 'OnlyFiles=""' >> $PFADAWSTATS
echo 'NotPageList="css js class gif jpg jpeg png bmp ico"' >> $PFADAWSTATS
echo 'ValidHTTPCodes="200 304"' >> $PFADAWSTATS
echo 'ValidSMTPCodes="1 250"' >> $PFADAWSTATS
echo 'AuthenticatedUsersNotCaseSensitive=0'>> $PFADAWSTATS
echo 'URLNotCaseSensitive=0' >> $PFADAWSTATS
echo 'URLWithAnchor=0' >> $PFADAWSTATS
echo 'URLQuerySeparators="?;"' >> $PFADAWSTATS
echo 'URLWithQuery=0' >> $PFADAWSTATS
echo 'URLWithQueryWithoutFollowingParameters=""' >> $PFADAWSTATS
echo 'URLReferrerWithQuery=0' >> $PFADAWSTATS
echo 'WarningMessages=1' >> $PFADAWSTATS
echo 'ErrorMessages=""' >> $PFADAWSTATS
echo 'DebugMessages=1' >> $PFADAWSTATS
echo 'NbOfLinesForCorruptedLog=50' >> $PFADAWSTATS
echo 'WrapperScript=""' >> $PFADAWSTATS
echo 'DecodeUA=0' >> $PFADAWSTATS
echo 'MiscTrackerUrl="/js/awstats_misc_tracker.js"' >> $PFADAWSTATS
echo 'LevelForRobotsDetection=2' >> $PFADAWSTATS
echo 'LevelForBrowsersDetection=2' >> $PFADAWSTATS
echo 'LevelForOSDetection=2' >> $PFADAWSTATS
echo 'LevelForRefererAnalyze=2' >> $PFADAWSTATS
echo 'UseFramesWhenCGI=0' >> $PFADAWSTATS
echo 'DetailedReportsOnNewWindows=1' >> $PFADAWSTATS
echo 'Expires=0' >> $PFADAWSTATS
echo 'MaxRowsInHTMLOutput=1000' >> $PFADAWSTATS
echo 'Lang="de"' >> $PFADAWSTATS
echo 'DirLang="./lang"' >> $PFADAWSTATS
echo 'ShowMenu=1' >> $PFADAWSTATS
echo 'ShowMonthStats=UVPHB' >> $PFADAWSTATS
echo 'ShowDaysOfMonthStats=VPHB' >> $PFADAWSTATS
echo 'ShowDaysOfWeekStats=PHB' >> $PFADAWSTATS
echo 'ShowHoursStats=PHB' >> $PFADAWSTATS
echo 'ShowDomainsStats=PHB' >> $PFADAWSTATS
echo 'ShowHostsStats=PHBL' >> $PFADAWSTATS
echo 'ShowAuthenticatedUsers=0' >> $PFADAWSTATS
echo 'ShowSessionsStats=1' >> $PFADAWSTATS
echo 'ShowPagesStats=PBEX' >> $PFADAWSTATS
echo 'ShowFileTypesStats=HB' >> $PFADAWSTATS
echo 'ShowOSStats=1' >> $PFADAWSTATS
echo 'ShowBrowsersStats=1' >> $PFADAWSTATS
echo 'ShowScreenSizeStats=0' >> $PFADAWSTATS
echo 'ShowOriginStats=PH' >> $PFADAWSTATS
echo 'ShowKeyphrasesStats=1' >> $PFADAWSTATS
echo 'ShowKeywordsStats=1' >> $PFADAWSTATS
echo 'ShowMiscStats=a' >> $PFADAWSTATS
echo 'ShowHTTPErrorsStats=1' >> $PFADAWSTATS
echo 'ShowSMTPErrorsStats=0' >> $PFADAWSTATS
echo 'ShowClusterStats=0' >> $PFADAWSTATS
echo 'AddDataArrayMonthStats=1' >> $PFADAWSTATS
echo 'AddDataArrayShowDaysOfMonthStats=1' >> $PFADAWSTATS
echo 'AddDataArrayShowDaysOfWeekStats=1' >> $PFADAWSTATS
echo 'AddDataArrayShowHoursStats=1' >> $PFADAWSTATS
echo 'MaxNbOfDomain = 10' >> $PFADAWSTATS
echo 'MinHitDomain = 1' >> $PFADAWSTATS
echo 'MaxNbOfHostsShown = 10' >> $PFADAWSTATS
echo 'MinHitHost = 1' >> $PFADAWSTATS
echo 'MaxNbOfLoginShown = 10' >> $PFADAWSTATS
echo 'MinHitLogin = 1' >> $PFADAWSTATS
echo 'MaxNbOfRobotShown = 10' >> $PFADAWSTATS
echo 'MinHitRobot = 1' >> $PFADAWSTATS
echo 'MaxNbOfPageShown = 10' >> $PFADAWSTATS
echo 'MinHitFile = 1' >> $PFADAWSTATS
echo 'MaxNbOfOsShown = 10' >> $PFADAWSTATS
echo 'MinHitOs = 1' >> $PFADAWSTATS
echo 'MaxNbOfBrowsersShown = 10' >> $PFADAWSTATS
echo 'MinHitBrowser = 1' >> $PFADAWSTATS
echo 'MaxNbOfScreenSizesShown = 5' >> $PFADAWSTATS
echo 'MinHitScreenSize = 1' >> $PFADAWSTATS
echo 'MaxNbOfRefererShown = 10' >> $PFADAWSTATS
echo 'MinHitRefer = 1' >> $PFADAWSTATS
echo 'MaxNbOfKeyphrasesShown = 10' >> $PFADAWSTATS
echo 'MinHitKeyphrase = 1' >> $PFADAWSTATS
echo 'MaxNbOfKeywordsShown = 10' >> $PFADAWSTATS
echo 'MinHitKeyword = 1' >> $PFADAWSTATS
echo 'MaxNbOfEMailsShown = 20' >> $PFADAWSTATS
echo 'MinHitEMail = 1' >> $PFADAWSTATS
echo 'FirstDayOfWeek=1' >> $PFADAWSTATS
echo 'ShowLinksOnUrl=1' >> $PFADAWSTATS
echo 'UseHTTPSLinkForUrl=""' >> $PFADAWSTATS
echo 'MaxLengthOfURL=70' >> $PFADAWSTATS
echo 'LinksToWhoIs="http://www.whois.net/search.cgi2?str="' >> $PFADAWSTATS
echo 'LinksToIPWhoIs="http://ws.arin.net/cgi-bin/whois.pl?queryinput="' >> $PFADAWSTATS
echo 'HTMLHeadSection=""' >> $PFADAWSTATS
echo 'HTMLEndSection=""' >> $PFADAWSTATS
echo 'Logo="awstats_logo6.png"' >> $PFADAWSTATS
echo 'LogoLink="http://awstats.sourceforge.net"' >> $PFADAWSTATS
echo 'BarWidth = 260' >> $PFADAWSTATS
echo 'BarHeight = 90' >> $PFADAWSTATS
echo '/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config='$2' -update' >> /usr/local/scripts/run_awstats
###### SCRIPT END #####
###### AWSTATS APACHE SECTION #####
apache config is done this way (in your case this would be in the master config and authentication would be done via db. Still awstats would be able to get the authenticatet username and provide the stats of atstats.example.com.config only to the guys mentioned in the line
# AllowAccessFromWebToFollowingAuthenticatedUsers="superuser reseller customername"
Alias /awstats /usr/local/awstats/wwwroot/
<Directory /usr/local/awstats/wwwroot>
AuthType Basic
AuthName "Enter pass for stats..."
AuthUserFile /etc/apache2/.htpasswd.d/awstats
<Limit GET>
require valid-user
</Limit>
</Directory>
<Directory /usr/local/awstats/wwwroot/cgi-bin>
AllowOverride All
AllowOverride FileInfo
Options +ExecCGI
</Directory>
###### REDIRCT START (my 00_master.conf) #####
<VirtualHost MYIP:80>
ServerAdmin info@example.com
ServerName example.com
RewriteEngine On
Redirect /
https://example.com/
ErrorLog /var/log/apache2/users/example.com-error.log
TransferLog /var/log/apache2/users/example.com-access.log
CustomLog /var/log/apache2/example.com-traf.log traff
CustomLog /var/log/apache2/example.com-combined.log combined
</VirtualHost>