To compute the data, a perl script is available in /usr/share/doc/awstats/examples. More you wait, more the log file grow in size, and more time it will take to process it. It’s a boring operation that should be done regularly (e.g, once a day, each 6 hours, etc…) depending on your need. We will now tell it to read the log files, and generate the stats from them. You could also enable some plugin, like GeoIP (require additional steps, beside uncommenting the line).Īwstats is now configured for each vhost.Set LogFormat to Combined (if you didn’t use the optional step in formatting the nginx log) LogFormat = 1.Remove LogFile, SiteDomain, DirData and HostAliases directive, as they’re useless outside their context.You’re free to add more setting if some of your vhost requires additional customization. You could change that to another directory, or have a subdirectory for each vhost, like /var/lib/awstats//.īut even if you use the default setting, you have to set it in each config, as it can not be inherited from. We start with an empty file, insert the following lines # Path to you nginx vhost log file LogFile = "/var/log/nginx/" # Domain of your vhost SiteDomain = "# Directory where to store the awstats data DirData = "/var/lib/awstats/" # Other alias, basically other domain/subdomain that's the same as the domain above HostAliases = "By default, awstats store all its data inside /var/lib/awstats/, which is the default settings. What I do is I copy all the contents of nf into, and just put the important rules inside each vhost config, so they’re easier to read, and shorter. If you have some rules that are shared among all your config, you put them here. It’s the parent of all the other config files. It’ll also fallback to this file if no other config file exists.Ī is an empty file. If you have ls the /etc/awstats folder, you’ll see that there’s by default 2 files here :Īnf is the main conf file, origin of all the other conf files. I’m personally not interested into having multiples conf files, for 1500 lines each, with each files differing of just 4 lines. If you take a look at nf, you’ll see that it’s a very complete conf, with plenty of comments, and all the available settings, all of that for just * suspense music * … 1500 lines. Then you just edit these files to your needs… Method I’m not fond of. Documentation says to clone that file when creating your own config files, with cp / ect / awstats / awstats. There is already a model configuration file inside the /ect/awstats/ directory : nf. So, for the vhost and, you should create these two files : Creating a configuration file for each vhostĪwstats is picky about the configuration files : you should have one config file by vhost, they should be named following the convention :, and should be placed inside the /ect/awstats/ directory. The last token ( %otherquot) means that “Oh, that string here does not mean anything.”. We teach awstats the meaning of each field when parsing the log. It’s used to set the settings shared by all your awstats config. In /etc/awstats/, add : LogFormat = " %host - %host_r %time1 %methodurl %code %bytesd %refererquot %uaquot %otherquot" log main Īs this last field is not used by awstats, we should tell it to ignore it. To use this format, add main at the end of your error_log directive. It’s the same as the combined format, plus the $http_x_forwarded_for bit at the end. In the server scope, add : log_format main '$remote_addr - $remote_user "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"' ). It’s used to capture the client IP address when he is connecting through a proxy of load balancer.įor that, we define another log format, named main in /etc/nginx/nf. Using the default format is fine, but you can log one more field, that could be pertinent : the http_x_forwarded_for. It’s equivalent to error_log / path / to / log. If you set your errors log like this : error_log / path / to / log. Nginx by default output logs that already can be read by awstats, as long as you use the Combined format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |