<p>Evennia has its own webserver. This should usually not be replaced. But another reason for wanting to use an external webserver like Apache would be to act as a <em>proxy</em> in front of the Evennia webserver. Getting this working with TLS (encryption) requires some extra work covered at the end of this page.</p>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>Possibly outdated
The Apache instructions below might be outdated. If something is not working right, or you use Evennia with a different server, please let us know.</p>
<h2>Running Apache as a proxy in front of Evennia<aclass="headerlink"href="#running-apache-as-a-proxy-in-front-of-evennia"title="Link to this heading">¶</a></h2>
<p>Below are steps to run Evennia using a front-end proxy (Apache HTTP), <codeclass="docutils literal notranslate"><spanclass="pre">mod_proxy_http</span></code>,
<codeclass="docutils literal notranslate"><spanclass="pre">mod_proxy_wstunnel</span></code>, and <codeclass="docutils literal notranslate"><spanclass="pre">mod_ssl</span></code>. <codeclass="docutils literal notranslate"><spanclass="pre">mod_proxy_http</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">mod_proxy_wstunnel</span></code> will simply be
referred to as <codeclass="docutils literal notranslate"><spanclass="pre">mod_proxy</span></code> below.</p>
<h3>Install <codeclass="docutils literal notranslate"><spanclass="pre">mod_ssl</span></code><aclass="headerlink"href="#install-mod-ssl"title="Link to this heading">¶</a></h3>
<li><p><em>Fedora/RHEL</em> - Apache HTTP Server and <codeclass="docutils literal notranslate"><spanclass="pre">mod_ssl</span></code> are available in the standard package repositories for Fedora and RHEL:</p>
<li><p><em>Ubuntu/Debian</em> - Apache HTTP Server and <codeclass="docutils literal notranslate"><spanclass="pre">mod_sslj</span></code>kl are installed together in the <codeclass="docutils literal notranslate"><spanclass="pre">apache2</span></code> package and available in the standard package repositories for Ubuntu and Debian. <codeclass="docutils literal notranslate"><spanclass="pre">mod_ssl</span></code> needs to be enabled after installation:</p>
<p>There is a slight trick in setting up Evennia so websocket traffic is handled correctly by the
proxy. You must set the <codeclass="docutils literal notranslate"><spanclass="pre">WEBSOCKET_CLIENT_URL</span></code> setting in your <codeclass="docutils literal notranslate"><spanclass="pre">mymud/server/conf/settings.py</span></code> file:</p>
<p>The setting above is what the client’s browser will actually use. Note the use of <codeclass="docutils literal notranslate"><spanclass="pre">wss://</span></code> is because our client will be communicating over an encrypted connection (“wss” indicates websocket over SSL/TLS). Also, especially note the additional path <codeclass="docutils literal notranslate"><spanclass="pre">/ws</span></code> at the end of the URL. This is how
Apache HTTP Server identifies that a particular request should be proxied to Evennia’s websocket
port but this should be applicable also to other types of proxies (like nginx).</p>
<h2>Run Apache instead of the Evennia webserver<aclass="headerlink"href="#run-apache-instead-of-the-evennia-webserver"title="Link to this heading">¶</a></h2>
This is covered because it has been asked about. The webclient would not work. It would also run out-of-process, leading to race conditions. This is not directly supported, so if you try this you are on your own.</p>
<h3>Install <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code><aclass="headerlink"href="#install-mod-wsgi"title="Link to this heading">¶</a></h3>
<li><p><em>Fedora/RHEL</em> - Apache HTTP Server and <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code> are available in the standard package
<li><p><em>Ubuntu/Debian</em> - Apache HTTP Server and <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code> are available in the standard package
<p>After <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code> is installed, copy the <codeclass="docutils literal notranslate"><spanclass="pre">evennia/web/utils/evennia_wsgi_apache.conf</span></code> file to your
apache2 vhosts/sites folder. On Debian/Ubuntu, this is <codeclass="docutils literal notranslate"><spanclass="pre">/etc/apache2/sites-enabled/</span></code>. Make your
modifications <strong>after</strong> copying the file there.</p>
<p>Read the comments and change the paths to point to the appropriate locations within your setup.</p>
<p>If your <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code> is set up to run on daemon mode (as will be the case by default on Debian and
Ubuntu), you may tell <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code> to reload by using the <codeclass="docutils literal notranslate"><spanclass="pre">touch</span></code> command on
<codeclass="docutils literal notranslate"><spanclass="pre">evennia/game/web/utils/apache_wsgi.conf</span></code>. When <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code> sees that the file modification time has
changed, it will force a code reload. Any modifications to the code will not be propagated to the
live instance of your site until reloaded.</p>
<p>If you are not running in daemon mode or want to force the issue, simply restart or reload apache2
<p>If you get strange (and usually uninformative) <codeclass="docutils literal notranslate"><spanclass="pre">Permission</span><spanclass="pre">denied</span></code> errors from Apache, make sure
that your <codeclass="docutils literal notranslate"><spanclass="pre">evennia</span></code> directory is located in a place the webserver may actually access. For example,
some Linux distributions may default to very restrictive access permissions on a user’s <codeclass="docutils literal notranslate"><spanclass="pre">/home</span></code>
directory.</p>
<p>One user commented that they had to add the following to their Apache config to get things to work.
Not confirmed, but worth trying if there are trouble.</p>