/**************************************************************************** ** ** Copyright (C) 2019 Luxoft Sweden AB ** Copyright (C) 2018 Pelagicore AG ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Auto Deployment Server. ** ** $QT_BEGIN_LICENSE:FDL-QTAS$ ** Commercial License Usage ** Licensees holding valid commercial Qt Automotive Suite licenses may use ** this file in accordance with the commercial license agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and The Qt Company. For ** licensing terms and conditions see https://www.qt.io/terms-conditions. ** For further information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free ** Documentation License version 1.3 as published by the Free Software ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements ** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \ingroup qtauto-deployment-server \page http-server-setup.html \previouspage Qt Automotive Suite Deployment Server API Reference \nextpage Upload Packages to the Deployment Server \startpage Qt Automotive Suite Deployment Server \title 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: \list \li reverse proxy setup - which we describe here \li WSGI setup - for brevity, this setup is left out of scope, as it is similar in functionality to reverse proxy setup \endlist \section1 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 \e{appstore/settings.py}, in a \c{URL_PREFIX} variable. In this example, this variable is set to 'url_prefix'; note the lack of slashes. Also, if \c{URL_PREFIX} is set to a non-empty value, \c{STATIC_URL} should be changed too, to start from set prefix. So \c{STATIC_URL} would be \c{'//static/'} instead of \c{'/static/'} After that, the server should be set up to run as a service, on any free port. This is done by running: \code ./venv/bin/python manage.py runserver 127.0.0.1: \endcode Assuming that the Python virtual environment was set up in the project directory, under the \e{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. \section2 Apache2 Setup First, enable \b{mod_proxy} and \b{mod_proxy_http} modules in Apache, by running \c{a2enmod proxy proxy_http}. Then insert this code snippet into the VirtualHost section of your configuration file: \code /'> ProxyPass "http://127.0.0.1://" ProxyPassReverse "http://127.0.0.1://" \endcode If necessary, add configuration section to set up access permissions to this URL. After setting this up, reload web server's configuration. \section2 Lighttpd Setup For Lighttpd, first, enable mod_proxy, by running \c{lighttpd-enable-mod proxy} as root. Alternatively, add the following line in your \e{/etc/lighttpd/lighttpd.conf} file: \code server.modules += ( "mod_proxy" ) \endcode Next, add the following code snippet: \code $HTTP["url"] =~ "^//" { proxy.balance = "hash" proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "" ), ) ) } \endcode Where \e{} is the same as in \e{settings.py} file, and \e{} is the port on which the Deployment Server instance is running. Finally, reload the Lighttpd server's configuration. \section2 Nginx Setup For Nginx, setup consists of adding a code snippet into server configuration, inside of a \c{server { } } statement and restarting the server. The code that needs to be added is: \code location // { proxy_pass http://127.0.0.1://; } \endcode Where \e{} is the same as in \e{settings.py} file, and \e{} is the port on which the Deployment Server instance is running. \section1 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 \e{static/} subdirectory of the Deployment Server installation as \e{static/} subdirectory of the instance. (If the Deployment Server is hosted as \e{http://deployment.server.name/}, then \e{static/} directory in the sources should be redirected to \e{http://deployment.server.name/static/}, while bypassing the django app.) After configuring that, static files collection should be performed using the following command: \code ./venv/bin/python manage.py collect static \endcode \section1 Serving static files outside of django app It is possible to speed up working of the admin pages of deployment server by serving static files separately. In order to achieve that, webserver should be configured to serve \e{static/} subdirectory of deployment server installation as \e{static/} subdirectory of the instance. (If deployment server is hosted as \e{http://deployment.server.name/}, then \e{static/} directory in the sources should be redirected to \e{http://deployment.server.name/static/}, while bypassing the django app.) After configuring that, static files collection should be performed with this command: \code ./venv/bin/python manage.py collect static \endcode */