Service setup

Finally, you have to setup the platfom services to serve your Django application.


As a service user create a nginx config /etc/nginx/local/django-mysite.conf to serve the Django application:

upstream @django {
    server localhost:8000;
    keepalive 10;

server {
    listen IPv4_FE_ADDRESS:80 default_server;
    listen [IPv6_FE_ADDRESS]:80;

    # Redirect to canonical host name (makes URLs unique).
    if ($host != $server_name) {
        rewrite . $scheme://$server_name$request_uri redirect;

    location / {
        proxy_pass http://@django;

Further common configuration options can be found in /etc/nginx/local/example-configuration. Please note that an nginx configuration file must end with .conf to get included.

Reload nginx:

sudo /etc/init.d/nginx reload

See the Web gateway role documentation for further details.

Log rotation

Create a snippet /var/spool/logrotate/SERVICE_USER with logrotate configuration like the following example:

/srv/SERVICE_USER/myproject/log/*.log {
      /srv/SERVICE_USER/myproject/bin/supervisorctl restart all

The log rotation will be invoked every night. The logrotate(8) man page documents available options. A set of standard options (like compress and dateext) will get applied automatically; see /etc/logrotate.options for reference.