<metaname="description"content="ENiGMA½ comes with a built in content server for supporting both HTTP and HTTPS. Currently the File Bases registers routes for file downloads, password reset email links are handled via the server, and static files can also be served for your BBS. Other features will likely come in the future or you can easily write your own!"/>
<metaproperty="og:description"content="ENiGMA½ comes with a built in content server for supporting both HTTP and HTTPS. Currently the File Bases registers routes for file downloads, password reset email links are handled via the server, and static files can also be served for your BBS. Other features will likely come in the future or you can easily write your own!"/>
{"mainEntityOfPage":{"@type":"WebPage","@id":"/enigma-bbs/servers/contentservers/web-server.html"},"description":"ENiGMA½ comes with a built in content server for supporting both HTTP and HTTPS. Currently the File Bases registers routes for file downloads, password reset email links are handled via the server, and static files can also be served for your BBS. Other features will likely come in the future or you can easily write your own!","url":"/enigma-bbs/servers/contentservers/web-server.html","@type":"BlogPosting","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"/enigma-bbs/assets/images/enigma-logo.png"}},"headline":"Web Server","dateModified":"2022-08-07T03:43:54+00:00","datePublished":"2022-08-07T03:43:54+00:00","@context":"https://schema.org"}</script>
<aclass="btn"style="float:left;margin-right: 20px;"href="/enigma-bbs/servers/loginservers/websocket.html">« Web Socket / Web Interface Server</a>
<ahref="#sidebar"class="btn menu_button">MENU</a>
<aclass="btn"style="float: right;margin-left: 20px"href="/enigma-bbs/servers/contentservers/gopher.html">Gopher Server »</a>
<brclear="both">
</div>
<divclass="page">
<h1class="page-title">Web Server</h1>
<p>ENiGMA½ comes with a built in <em>content server</em> for supporting both HTTP and HTTPS. Currently the <ahref="../modding/file-base-web-download-manager.md">File Bases</a> registers routes for file downloads, password reset email links are handled via the server, and static files can also be served for your BBS. Other features will likely come in the future or you can easily write your own!</p>
<h1id="configuration">Configuration</h1>
<p>By default the web server is not enabled. To enable it, you will need to at a minimum configure two keys in the <codeclass="language-plaintext highlighter-rouge">contentServers.web</code> section of <codeclass="language-plaintext highlighter-rouge">config.hjson</code>:</p>
<td>Overrides the default certificate path of <codeclass="language-plaintext highlighter-rouge">/config/https_cert.pem</code>. Certificate must be in PEM format. See <strong>Certificates</strong> below.</td>
<td>Overrides the default certificate key path of <codeclass="language-plaintext highlighter-rouge">/config/https_cert_key.pem</code>. Key must be in PEM format. See <strong>Certificates</strong> below.</td>
</tr>
</tbody>
</table>
<h4id="certificates">Certificates</h4>
<p>If you don’t have a TLS certificate for your domain, a good source for a certificate can be <ahref="https://letsencrypt.org/">Let’s Encrypt</a> who supplies free and trusted TLS certificates. A common strategy is to place another web server such as <ahref="https://caddyserver.com/">Caddy</a> in front of ENiGMA½ acting as a transparent proxy and TLS termination point.</p>
<p><imgclass="emoji"title=":information_source:"alt=":information_source:"src="https://github.githubassets.com/images/icons/emoji/unicode/2139.png"height="20"width="20"> Keep in mind that the SSL certificate provided by Let’s Encrypt’s Certbot is by default stored in a privileged location; if your ENIGMA instance is not running as root (which it should not be!), you’ll need to copy the SSL certificate somewhere else in order for ENIGMA to use it.</p>
<p>Static files live relative to the <codeclass="language-plaintext highlighter-rouge">contentServers.web.staticRoot</code> path which defaults to <codeclass="language-plaintext highlighter-rouge">enigma-bbs/www</code>.</p>
<p><codeclass="language-plaintext highlighter-rouge">index.html, favicon.ico</code>, and any error pages like <codeclass="language-plaintext highlighter-rouge">404.html</code> are accessible from the route path. Other static assets hosted by the web server must be referenced from <codeclass="language-plaintext highlighter-rouge">/static/</code>, for example:</p>
<divclass="language-html highlighter-rouge"><divclass="highlight"><preclass="highlight"><code><spanclass="nt"><a</span><spanclass="na">href=</span><spanclass="s">"/static/about.html"</span><spanclass="nt">></span> Example Link
<p>Customized error pages can be created for <ahref="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error">HTTP error codes</a> by providing a <codeclass="language-plaintext highlighter-rouge"><error_code>.html</code> file in the <em>static routes</em> area. For example: <codeclass="language-plaintext highlighter-rouge">404.html</code>.</p>
</div>
<divclass="PageNavigation">
<aclass="btn"style="float:left;margin-right: 20px;"href="/enigma-bbs/servers/loginservers/websocket.html">« Web Socket / Web Interface Server</a>
<aclass="btn"style="float: right;margin-left: 20px"href="/enigma-bbs/servers/contentservers/gopher.html">Gopher Server »</a>