Skip to content
Myr

apache-httpd.rst

This file

Path

docs/deploying/apache-httpd.rst

66 lines · 2.3 KiB

Last changed by

Merge branch '2.1.x'David Lordbefore adoption9139af1

History of this file

Take it

1Apache httpd2============34`Apache httpd`_ is a fast, production level HTTP server. When serving5your application with one of the WSGI servers listed in :doc:`index`, it6is often good or necessary to put a dedicated HTTP server in front of7it. This "reverse proxy" can handle incoming requests, TLS, and other8security and performance concerns better than the WSGI server.910httpd can be installed using your system package manager, or a pre-built11executable for Windows. Installing and running httpd itself is outside12the scope of this doc. This page outlines the basics of configuring13httpd to proxy your application. Be sure to read its documentation to14understand what features are available.1516.. _Apache httpd: https://httpd.apache.org/171819Domain Name20-----------2122Acquiring and configuring a domain name is outside the scope of this23doc. In general, you will buy a domain name from a registrar, pay for24server space with a hosting provider, and then point your registrar25at the hosting provider's name servers.2627To simulate this, you can also edit your ``hosts`` file, located at28``/etc/hosts`` on Linux. Add a line that associates a name with the29local IP.3031Modern Linux systems may be configured to treat any domain name that32ends with ``.localhost`` like this without adding it to the ``hosts``33file.3435.. code-block:: python36    :caption: ``/etc/hosts``3738    127.0.0.1 hello.localhost394041Configuration42-------------4344The httpd configuration is located at ``/etc/httpd/conf/httpd.conf`` on45Linux. It may be different depending on your operating system. Check the46docs and look for ``httpd.conf``.4748Remove or comment out any existing ``DocumentRoot`` directive. Add the49config lines below. We'll assume the WSGI server is listening locally at50``http://127.0.0.1:8000``.5152.. code-block:: apache53    :caption: ``/etc/httpd/conf/httpd.conf``5455    LoadModule proxy_module modules/mod_proxy.so56    LoadModule proxy_http_module modules/mod_proxy_http.so57    ProxyPass / http://127.0.0.1:8000/58    RequestHeader set X-Forwarded-Proto http59    RequestHeader set X-Forwarded-Prefix /6061The ``LoadModule`` lines might already exist. If so, make sure they are62uncommented instead of adding them manually.6364Then :doc:`proxy_fix` so that your application uses the ``X-Forwarded``65headers. ``X-Forwarded-For`` and ``X-Forwarded-Host`` are automatically66set by ``ProxyPass``.