Xonotic Forums
[How to] Linux map file server - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Server Administration (https://forums.xonotic.org/forumdisplay.php?fid=16)
+--- Thread: [How to] Linux map file server (/showthread.php?tid=5133)



[How to] Linux map file server - end user - 10-17-2014

This is a how to on setting up a file host for your maps if you are running on Linux, either on a VPS or Dedicated server. With this how to you'll only have to have maps in one location vs normally done with two, one inside your .xonotic/data folder and one on the map host.

I'm going to assume you have your Linux distro installed already and basic secured. I'll be doing this for Ubuntu server but should the same for most distros. I'm also going to assume that you have Xonotic already downloaded and for GIT version compiled it.


Now open up a command line window

In the /home/your_name/.xonotic folder make a directory called maps

Code:
mkdir maps

Now lets install lighttpd

Code:
sudo apt-get install lighttpd

Accept all the install defaults, usually just type in y or Y

Now type in

Code:
sudo nano /etc/lighttpd/lighttpd.conf

This will bring up the lighttpd config file in the nano editor.

Check that the following lines are not commented out. They should't be anyways.

Code:
server.modules = (
        "mod_access",

Leave this line as it for now. You can set it to what ever you want later.

Code:
server.document-root        = "/var/www"

Change this line

Code:
url.access-deny             = ( "~", ".inc")

to

Code:
url.access-deny             = ( "~", ".inc", ".cfg", ".db", ".txt" )

This will make the server make these file extensions unavailable through the browser. Just in-case you upload them to the wrong folder.


Now add this line below it. It will deny access to any file in the maps/data dir. Not sure if its needed but why not.

Code:
# deny access to /maps/data
$HTTP["url"] =~ "^/maps/data/" {
     url.access-deny = ("")
}

Click CTRL+x and then Y to save the changes.

Now type in

Code:
service lighttpd restart

Now type in

Code:
cd /var/www

which will take you to the /var/www directory. Here will we create a symlink that points to /home/your_name/.xonotic/maps

Now type in

Code:
sudo ln -s /home/your_name/.xonotic/maps maps

Open up you serer.cfg file and look for this like

Code:
// see Docs/mapdownload.txt for more info
sv_curl_defaulturl ""  //fallback download URL

Uncomment it by remove the # before sv_curl_defaulturl and make it look like this with your info

Code:
// see Docs/mapdownload.txt for more info
sv_curl_defaulturl "http://your_ip/maps/"  //fallback download URL

This will tell the player client where it should download the next map from.


With this your .pk3 map files will be downloadable for the players when they join your server. They will also be downloadable from the browser if the user goes to say your_site.com/maps.

Now when you want to upload your map files they just have to be uploaded to one location /home/your_name/.xonotic/maps

For the final set up

When you start your xonotic server you'll need do use the -game switch like this

For GIT
Code:
./all run dedicated -game maps

This will tell the game to use the /home/your_name/.xonotic/data/maps directory for the map .pk3 files. Your server.cfg can and should now be placed in the /home/your_name/.xonotic/data directory and not /home/your_name/.xonotic/maps

Depending on how popular your server is and how many maps you are hosting, having the map server on the same box might cause some lag when players are downloading maps. I haven't noticed this but might be noticeable on a small VPS.


RE: [How to] Linux map file server - machine! - 10-18-2014

+1


RE: [How to] Linux map file server - end user - 10-18-2014

I'll add some screen shots to this a bit later.


RE: [How to] Linux map file server - Mr. Bougo - 10-19-2014

Using "-game maps" is weird. Does your server show in the server list at all when you do that? Why not instead keep "data" and configure lighttpd to have "maps" point to that directory.

In any case, I would advise against making your server data directory the document root. You are putting every single file (except for your crypto key, thankfully) of your dedicated server on a web server. That's generally a bad idea. Though you do revoke access to specific extensions, you can't predict every pattern that non-map files will follow on your server. For example, here you're making savegames and server demos accessible.

Instead of this, I would advise that you put your maps in .xonotic/maps or anywhere else you would like to, and create symbolic links from your server's data directory to that map directory. That way, you can ditch mod_access and have full control over what files are accessible rather than relying on guesses that end up exposing data that you don't necessarily want out in the public.


RE: [How to] Linux map file server - end user - 10-19-2014

(10-19-2014, 01:47 PM)Mr. Bougo Wrote: Using "-game maps" is weird. Does your server show in the server list at all when you do that? Why not instead keep "data" and configure lighttpd to have "maps" point to that directory.

In any case, I would advise against making your server data directory the document root. You are putting every single file (except for your crypto key, thankfully) of your dedicated server on a web server. That's generally a bad idea. Though you do revoke access to specific extensions, you can't predict every pattern that non-map files will follow on your server. For example, here you're making savegames and server demos accessible.

Instead of this, I would advise that you put your maps in .xonotic/maps or anywhere else you would like to, and create symbolic links from your server's data directory to that map directory. That way, you can ditch mod_access and have full control over what files are accessible rather than relying on guesses that end up exposing data that you don't necessarily want out in the public.

The symlink is from /var/www to .xonotic/maps not .xonotic/data/maps for the -game switch this is what Mario suggested. The user would only put maps/server_packages to the .xonotic/maps folder while the other data like server.cfg stays in .xonotic/data

Also

Code:
# deny access to /maps/data
$HTTP["url"] =~ "^/maps/data/" {
     url.access-deny = ("")
}

This give a 403 Forbidden to any file/dir under the .xonotic/maps/data dir.

Ok I guess if I don't have to use the -game switch and the game will use the .xonotic/maps then yes it would be better that way and symlink from .xonotic/maps to /var/www/maps

I'll have to test this locally first.


RE: [How to] Linux map file server - Mr. Bougo - 10-19-2014

Sure, .xonotic/maps/data is blocked, but .xonotic/maps/sv_autodemos is not. Same thing about savegames, for which you can't predict a file name pattern. Those features aren't used very often, but IIRC autodemos can contain sensitive data like rcon or master passwords. And I'm possibly missing other files that are written in the data directory.

Considering that, I would recommend that users exert caution if they follow your guide above in its current form.


RE: [How to] Linux map file server - end user - 10-19-2014

(10-19-2014, 03:56 PM)Mr. Bougo Wrote: Sure, .xonotic/maps/data is blocked, but .xonotic/maps/sv_autodemos is not. Same thing about savegames, for which you can't predict a file name pattern. Those features aren't used very often, but IIRC autodemos can contain sensitive data like rcon or master passwords. And I'm possibly missing other files that are written in the data directory.

Considering that, I would recommend that users exert caution if they follow your guide above in its current form.

Ok so I can either add all the available dir's under .xonotic/maps to be excluded or I can block all files BUT pk3 to be served.

Code:
$HTTP["url"] !~ "\.(pk3)$" {
  url.access-deny = ( "" )
}



RE: [How to] Linux map file server - Mr. Bougo - 10-19-2014

Sure, that might work too. I personally prefer physically separating the data you want to serve, it seems less foolproof to me. Your new suggestion looks reasonable however.


RE: [How to] Linux map file server - Smilecythe - 10-21-2014

I thought you were supposed to speak English in this forum Blush