From 3721e324b6571088d6940a8b37a1c5bd7ca394aa Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 19 Sep 2020 13:52:39 -0700 Subject: [PATCH] Add a README file for the lmno-server repository It's been a while since I did any LMNO development, and since the last time I did, I'm now using a new laptop. So I needed a reminder on how to configure my web server for local development. Here that is now for my own use, (and for the use of anyone else that might want it). --- README | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..d6b1de1 --- /dev/null +++ b/README @@ -0,0 +1,94 @@ +Server-side implementation for LMNO games. + +This repository contains the server-side implementation for a number +of games that are hosted at the https://lmno.games/ website. + +Deployment +---------- + +The initial deployment of the LMNO server requires configuring a web +server. Instructions are provided below for any web server, along with +specific configuration examples for Apache. If you are using a +non-Apache server (such as nginx) the general concepts will still +apply, but the syntax of the configuration will be different. + +First, you need to configure your web server to serve the static +content of the LMNO implementation. This static content is actually in +a separate git repository (lmno.games) which you should be able to +find near where you found the current repository (lmno-server). + +So, first, copy the static files from the lmno.games repository to +your server (there's a "make deploy" target in the lmno.games +repository's Makefile that can help with this). + +Then, configure your web server to serve the content that you have +deployed. Specifically, you want the server to match the path from the +request to the local filesystem and serve the local file whenever +there is a match. The syntax for this with Apache is as follows +(substitute the path you chose if anything other than +"/srv/lmno.games/www"): + + DocumentRoot /srv/lmno.games/www + + Options Indexes + + + + Require all granted + + + RewriteEngine on + + # Any static files (or directories) that exist within the + # DocumentRoot are served directly by Apache as a first priority. + RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] + RewriteCond %{DOCUMENT_ROOT}/$1 -d + RewriteRule (.*) - [L] + +Note: The above configuration requires both the "rewrite" and "proxy" +and "proxy_http" Apache modules to be installed and enabled. On some +operating systems this can be achieved with the following commands: + + sudo a2enmod rewrite + sudo a2enmod proxy + sudo a2enmod proxy_http + +Also, you will need to configure Apache to proxy to the node server +any requests that _don't_ match a static file. Assuming you're running +the LMNO node server on port 4000 (which the code currently defaults +to) you would add the following Apache configuration just after the +block above: + + # Otherwise, for any path that does not exist in the filesystem + # we proxy to the dynamic web app to let it serve the resource. + RewriteRule ^/(.*)$ http://localhost:4000/$1 [P] + ProxyPassReverse / http://localhost:4000 + +And, of course, after changing Apache configuration, you'll need to +restart the Apache service. + +Finally, you'll need to arrange to start the node process on port 4000 +that will serve the dynamic LMNO content. This is as simple as +running: + + node lmno + +Which must be run from the directory containing the lmno.js file. And +of course, this could be wired into an lmno service to enable this to +be started each time the machine boots. + +Once this configuration is complete and working, any updates to the +code will simply requiring terminating the node process and then +starting it up again. + +Development +----------- + +For testing changes to the implementation locally, we recommend doing +the exact same deployment described above on a local machine, (that +is, configure a web server to serve static content from the lmno.games +repository and to proxy dynamic content to the node process). You +might simply configure and access this at http://localhost/ if you're +not already using a local web server for any other purpose. Otherwise, +configure your webserver with whatever hostname and top-level path you +prefer. -- 2.43.0