Set up a Production server with Apache, Lighttpd or Nginx

The Deployment Server can be set up in combination with a regular web server: Apache, Lighttpd, or Nginx. This web server can be used to reduce the number of open ports or to add a layer of SSL encryption.

There are two possible setups for running with another web server in the Django version used for the Deployment Server:

  • reverse proxy setup - which we describe here
  • WSGI setup - for brevity, this setup is left out of scope, as it is similar in functionality to reverse proxy setup

Reverse Proxy Setup

For all web servers, the preliminary setup is the same. First, the deployment server should be set up in the same way as for standalone use. If the server will be used in a subdirectory of the web server (like http://hostname.domain/url_prefix/ ), then this prefix should be set up in appstore/, in a URL_PREFIX variable.

In this example, this variable is set to 'url_prefix'; note the lack of slashes. Also, if URL_PREFIX is set to a non-empty value, STATIC_URL should be changed too, to start from set prefix. So STATIC_URL would be '/<url_prefix>/static/' instead of '/static/'

After that, the server should be set up to run as a service, on any free port. This is done by running:

./venv/bin/python runserver<port>

Assuming that the Python virtual environment was set up in the project directory, under the venv subdirectory.

On Linix and Unix systems, to run as a non-root user, you must use a port number larger than 1024.

Once the service is running, set up the web server's configuration.

Apache2 Setup

First, enable mod_proxy and mod_proxy_http modules in Apache, by running a2enmod proxy proxy_http.

Then insert this code snippet into the VirtualHost section of your configuration file:

<Location '/<url_prefix>/'>
        ProxyPass "<port>/<url_prefix>/"
        ProxyPassReverse "<port>/<url_prefix>/"

If necessary, add configuration section to set up access permissions to this URL.

After setting this up, reload web server's configuration.

Lighttpd Setup

For Lighttpd, first, enable mod_proxy, by running lighttpd-enable-mod proxy as root. Alternatively, add the following line in your /etc/lighttpd/lighttpd.conf file:

server.modules   += ( "mod_proxy" )

Next, add the following code snippet:

$HTTP["url"] =~ "^/<url_prefix>/" {
      proxy.balance = "hash"
      proxy.server  = ( "" => ( ( "host" => "", "port" => "<port>" ),
                              ) )

Where <url_prefix> is the same as in file, and <port> is the port on which the Deployment Server instance is running.

Finally, reload the Lighttpd server's configuration.

Nginx Setup

For Nginx, setup consists of adding a code snippet into server configuration, inside of a server { } statement and restarting the server.

The code that needs to be added is:

location /<url_prefix>/ {

Where <url_prefix> is the same as in file, and <port> is the port on which the Deployment Server instance is running.

Serving Static Files Outside of Django App

It is possible to speed up working of the admin pages of the Deployment Server by serving static files separately. In order to achieve that, web server should be configured to serve static/ subdirectory of the Deployment Server installation as static/ subdirectory of the instance. (If the Deployment Server is hosted as, then static/ directory in the sources should be redirected to, while bypassing the django app.)

After configuring that, static files collection should be performed using the following command:

./venv/bin/python collect static

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.