]> git.cworth.org Git - lmno-server/blob - README
d6b1de1d567cd1e0b6b78ea46941d10ed77e1c02
[lmno-server] / README
1 Server-side implementation for LMNO games.
2
3 This repository contains the server-side implementation for a number
4 of games that are hosted at the https://lmno.games/ website.
5
6 Deployment
7 ----------
8
9 The initial deployment of the LMNO server requires configuring a web
10 server. Instructions are provided below for any web server, along with
11 specific configuration examples for Apache. If you are using a
12 non-Apache server (such as nginx) the general concepts will still
13 apply, but the syntax of the configuration will be different.
14
15 First, you need to configure your web server to serve the static
16 content of the LMNO implementation. This static content is actually in
17 a separate git repository (lmno.games) which you should be able to
18 find near where you found the current repository (lmno-server).
19
20 So, first, copy the static files from the lmno.games repository to
21 your server (there's a "make deploy" target in the lmno.games
22 repository's Makefile that can help with this).
23
24 Then, configure your web server to serve the content that you have
25 deployed. Specifically, you want the server to match the path from the
26 request to the local filesystem and serve the local file whenever
27 there is a match. The syntax for this with Apache is as follows
28 (substitute the path you chose if anything other than
29 "/srv/lmno.games/www"):
30
31         DocumentRoot /srv/lmno.games/www
32         <Directory /srv/lmno.games/www>
33                 Options Indexes
34         </Directory>
35
36         <Location />
37                 Require all granted
38         </Location>
39
40         RewriteEngine on
41
42         # Any static files (or directories) that exist within the
43         # DocumentRoot are served directly by Apache as a first priority.
44         RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR]
45         RewriteCond %{DOCUMENT_ROOT}/$1 -d
46         RewriteRule (.*) - [L]
47
48 Note: The above configuration requires both the "rewrite" and "proxy"
49 and "proxy_http" Apache modules to be installed and enabled. On some
50 operating systems this can be achieved with the following commands:
51
52         sudo a2enmod rewrite
53         sudo a2enmod proxy
54         sudo a2enmod proxy_http
55
56 Also, you will need to configure Apache to proxy to the node server
57 any requests that _don't_ match a static file. Assuming you're running
58 the LMNO node server on port 4000 (which the code currently defaults
59 to) you would add the following Apache configuration just after the
60 block above:
61
62         # Otherwise, for any path that does not exist in the filesystem
63         # we proxy to the dynamic web app to let it serve the resource.
64         RewriteRule ^/(.*)$ http://localhost:4000/$1 [P]
65         ProxyPassReverse / http://localhost:4000
66
67 And, of course, after changing Apache configuration, you'll need to
68 restart the Apache service.
69
70 Finally, you'll need to arrange to start the node process on port 4000
71 that will serve the dynamic LMNO content. This is as simple as
72 running:
73
74         node lmno
75
76 Which must be run from the directory containing the lmno.js file. And
77 of course, this could be wired into an lmno service to enable this to
78 be started each time the machine boots.
79
80 Once this configuration is complete and working, any updates to the
81 code will simply requiring terminating the node process and then
82 starting it up again.
83
84 Development
85 -----------
86
87 For testing changes to the implementation locally, we recommend doing
88 the exact same deployment described above on a local machine, (that
89 is, configure a web server to serve static content from the lmno.games
90 repository and to proxy dynamic content to the node process). You
91 might simply configure and access this at http://localhost/ if you're
92 not already using a local web server for any other purpose. Otherwise,
93 configure your webserver with whatever hostname and top-level path you
94 prefer.