If you use nginx+apache and awstats, and stats shows too low values of used bandwidth, and in directadmin you see the bandwidth usage is much higher than in Awstats. Here is why this happens.
This all is due to how nginx proxies requests with the help of X-Accel to apache when you use nginx+apache on directadmin server.
X-accel allows for internal redirection to a location determined by a header returned from a backend.
This allows you to handle authentication, logging or whatever else you please in your backend and then have NGINX handle serving the contents from redirected location to the end user, thus freeing up the backend to handle other requests. This feature is commonly known as X-Sendfile.
This feature differs a bit from standard NGINX modules as it does not rely on directives but rather handles headers from upstream in a special way. The way it works is that you send the header x-accel.redirect with a URI. NGINX will match this URI against its locations as if it was a normal request. It will then serve the location that matches the defined root + URI passed in the header.
Images (static files) requested through nginx/apache are fully logged with its size only in nginx logs. And apache logs size of only tech headers (approximately 300 bytes), which usually looks similar to the following:
HTTP/1.1 200 OK Date: Tue, 10 Jan 2012 02:59:02 GMT Server: Apache/2.2.21 (FreeBSD) X-Accel-Version: 0.01 X-Accel-Redirect: /int/some/static/file.txt Content-Length: 0 Content-Type: text/plain
As a quick solution run this:
perl -pi -e 's|/var/log/httpd/domains/|/var/log/nginx/domains/|' /home/*/domains/*/awstats/.data/awstat*.conf
to make awstats to read nginx logs instead of apache. This changes will affect only existing domains. Newly created domains will still have awstat reading apache logs.
Run this:
perl -pi -e 's|/var/log/nginx/domains/|/var/log/httpd/domains/|' /home/*/domains/*/awstats/.data/awstat*.conf
to roll back and make awstats to read apache logs instead of nginx. This changes will affect only existing domains.
Related links: