How do I successfully deploy the serverlist software to Debian & Apache?

Post Reply
User avatar
Blockhead
Member
Posts: 1623
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

How do I successfully deploy the serverlist software to Debian & Apache?

by Blockhead » Post

The serverlist software, which powers servers.minetest.net, is available as free software. It is written in Python and uses Flask.

However, the instructions and documentation are pretty scant. I have had trouble trying to set up my server. I am no expert, but I have got Apache httpd already running serving a website on port 80. I do not mind whether I run the server list on a different port, but a subdirectory would be a nice option I think. Whatever works I'll take..

So far the working looks like this:

Code: Select all

git clone https://github.com/minetest/serverlist/
cd serverlist
sudo apt install python3 python3-pip libapache2-mod-wsgi-py3
pip install -r requirements.txt
cp config-example.py config.py
cd ..
sudo mkdir -p /var/games/minetest/serverlist
sudo cp -r serverlist/* /var/games/minetest/serverlist
sudo vim /etc/apache2/sites-available/10-serverlist.conf
10-serverlist.conf

Code: Select all

<VirtualHost *:5000>
        DocumentRoot /var/games/minetest/serverlist

        WSGIScriptAlias /serverlist/ /var/games/minetest/serverlist/server.py

        WSGICallableObject app

        WSGIProcessGroup minetest-serverlist
        WSGIDaemonProcess minetest-serverlist threads=2

        <Directory /var/games/minetest/serverlist>
                Require all granted
        </Directory>

</VirtualHost>

Code: Select all

cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/10-serverlist.conf 10-serverlist.conf
sudo ufw allow 5000
sudo apache2ctl restart
However, I can't get a response out of port 5000, either locally with curl or across the internet with Firefox. I have a feeling I am supposed to write step 7 into the site config as well, but that seems less important. My VPS provider normally doesn't block ports to my knowledge, at least not high range ports like this, I haven't tried mail..

If I instead try to run the development server, /var/games/minetest/serverlist/server.py through my SSH session, then I can at least get a response from curl locally. However, GET /list, /list.json and so on will 404, probably because there are no servers that have successfully announced. That brings me to the next problem. This system already runs minetestserver as a daemon. The relevant parts of minetest.conf are:

Code: Select all

server_address = [redacted internet domain name of server]
server_announce = true
serverlist_url = http://127.0.0.1:5000
minetestserver will find the server at 127.0.0.1:5000 and make what looks like successful requests at first, but then there is some kind of clever matching of IP address that the HTTP connection comes from against which server is encoded in the JSON body, which seems to mismatch when Minetest is running on the same node as the serverlist. The serverlist console looks like this:

Code: Select all

127.0.0.1 - - [06/Jun/2023 04:22:02] "POST /announce HTTP/1.1" 200 -
127.0.0.1 - - [06/Jun/2023 04:22:24] "POST /announce HTTP/1.1" 202 -
[2023-06-06 04:22:24,617] WARNING in server: Invalid IP 127.0.0.1 for address [internet domain name of server] (address valid for {'127.0.1.1'}).
Thus, the server won't get listed. I'm not sure where cause and effect start any more either, but with no servers in the list, it seems the server list can't be fetched over curl - but again, I was wondering if I needed a rewrite rule for that anyway..:

Code: Select all

$ curl http://127.0.0.1:5000/list
$ curl http://127.0.0.1:5000/list.json
$ curl http://127.0.0.1:5000/static/list
$ curl http://127.0.0.1:5000/static/list.json
All of those go 404.

So how do I fix this? Is my firewall bad? I've also tried removing the check, but no luck. Patch for server.py is:

Code: Select all

314a315,321
> 	if checkAddress:
> 		addresses = set(data[4][0] for data in info)
> 		if not server["ip"] in addresses:
> 			app.logger.warning("Invalid IP %s for address %s (address valid for %s)."
> 					% (server["ip"], server["address"], addresses))
> 			return
> 

Afterwards: still no response when getting the list from the outside internet - connection reset according to wireshark I think, and nothing but 404 from curl on the inside.

This leaves me a with a few head-scratchers:
  • Is my firewall still somehow missing a rule? I thought ufw was just about foolproof.
  • Is there a missing setup step, like touch static/list.json, or is the file meant to come into being through normal program operation? How do I write any necessary rewrite rules for it?
  • Why doesn't my apache site work at all when executing the python file does? How do I debug/get logs on that?
Thanks in advance for your help.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests