<h1>Configuring an Apache Proxy<aclass="headerlink"href="#configuring-an-apache-proxy"title="Permalink to this headline">¶</a></h1>
<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="Permalink to this headline">¶</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>
<sectionid="install-mod-ssl">
<h3>Install <codeclass="docutils literal notranslate"><spanclass="pre">mod_ssl</span></code><aclass="headerlink"href="#install-mod-ssl"title="Permalink to this headline">¶</a></h3>
<ul>
<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>
<h4>Evennia secure websocket configuration<aclass="headerlink"href="#evennia-secure-websocket-configuration"title="Permalink to this headline">¶</a></h4>
<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="Permalink to this headline">¶</a></h2>
<divclass="admonition warning">
<pclass="admonition-title">Warning</p>
<p>This is not supported, nor recommended.
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>
</div>
<sectionid="install-mod-wsgi">
<h3>Install <codeclass="docutils literal notranslate"><spanclass="pre">mod_wsgi</span></code><aclass="headerlink"href="#install-mod-wsgi"title="Permalink to this headline">¶</a></h3>
<ul>
<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
<h3>Copy and modify the VHOST<aclass="headerlink"href="#copy-and-modify-the-vhost"title="Permalink to this headline">¶</a></h3>
<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>
</section>
<sectionid="restart-reload-apache">
<h3>Restart/Reload Apache<aclass="headerlink"href="#restart-reload-apache"title="Permalink to this headline">¶</a></h3>
<p>You’ll then want to reload or restart apache2 after changing the configurations.</p>
<p>With any luck, you’ll be able to point your browser at your domain or subdomain that you set up in
your vhost and see the nifty default Evennia webpage. If not, read the hopefully informative error
message and work from there. Questions may be directed to our <aclass="reference external"href="https://evennia.com">Evennia Community
site</a>.</p>
</section>
<sectionid="a-note-on-code-reloading">
<h3>A note on code reloading<aclass="headerlink"href="#a-note-on-code-reloading"title="Permalink to this headline">¶</a></h3>
<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
to apply your changes.</p>
</section>
<sectionid="further-notes-and-hints">
<h3>Further notes and hints:<aclass="headerlink"href="#further-notes-and-hints"title="Permalink to this headline">¶</a></h3>
<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>