I will show you how to configure the AWStats web-interface using the uWSGI application server and Nginx HTTP server, which is a very simple and straightforward process.

Configure AWStats

Install the AWStats package.

$ sudo apt-get install awstats

Configure it according to your needs. I will leave it up to you to perform this step as it is specific to your setup.

I am using global /etc/awstats/awstats.conf.local override file to use HTML frames, display the top menu, and allow to initiate update process directly from the browser.

$ sudo cat awstats.conf.local
# You can overrides config directives here.
# This is particularly useful for users with several configs for
# different virtual servers, who want to reuse common parameters.
# Also, this file is not updated with each new upstream release.

# use frames
UseFramesWhenCGI=1

# show top menu (last update, reported period, filters, initiate update)
ShowMenu=1

# allow to initiate update from browser an use lock file
AllowToUpdateStatsFromBrowser=1
EnableLockForUpdate=1

Install uWSGI

Install uWSGI package.

$ sudo apt-get --no-install-recommends install uwsgi

Configure uWSGI application

Define AWStats application.

$ cat << EOF | sudo tee /etc/uwsgi/apps-available/awstats.ini
[uwsgi]
plugins      = router_basicauth, cgi
route        = ^/ basicauth:awstats,secret-user:secret-password
uid          = www-data
gid          = www-data
processes    = 1
threads      = 2
cgi           = /usr/lib/cgi-bin/awstats.pl
chown-socket = www-data:www-data
EOF

I have added basic authentication (user secret-user and password secret-password) to protect statistics. You can use htpasswd file or utilize the HTTP server to take care of the authentication process.

Enable application.

$ sudo ln -s /etc/uwsgi/apps-available/awstats.ini /etc/uwsgi/apps-enabled/

Reload application server configuration.

$ sudo systemctl restart uwsgi

Install Nginx

Install nginx package.

$ sudo apt-get install nginx

Configure Nginx

Disable default Nginx site.

$ sudo unlink /etc/nginx/sites-enabled/default

Prepare Nginx virtual host configuration (statistics.example.org in this example).

$ cat << EOF | sudo tee /etc/nginx/sites-available/statistics.example.org
server {
  listen 80;
  server_name statistics.example.org;

  location / {
    include uwsgi_params;
    uwsgi_modifier1 9;
    uwsgi_pass unix:/var/run/uwsgi/app/awstats/socket;

    rewrite ^/\$ \$scheme://statistics.example.org/awstats.pl?config=example.org permanent;
  }

  location /awstats-icon/ {
    alias /usr/share/awstats/icon/;
    expires 30d;
  }
}
EOF
Notice the rewrite rule to open the default awstats configuration.

Enable virtual host.

$ sudo ln -s /etc/nginx/sites-available/statistics.example.org /etc/nginx/sites-enabled/

Reload HTTP server configuration.

$ sudo systemctl reload nginx

It is as simple as that.

References

The uWSGI project

The uWSGI project – The uwsgi Protocol

The uWSGI project – uWSGI internal routing