• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Server Dedicated Killing Floor 2 Server on Linux [step-by-step guide]

bviktor

Active member
Oct 9, 2017
41
3
44
Hey all. I put around 3 weeks of work into properly setting up a dedicated CentOS 7 server. So I thought I might as well save others the time and energy and document it. Plus wrote a bunch of scripts which makes the whole process _way_ easier.

Most guides focus on Windows and Ubuntu, they don't really care about firewalls, proper map redirection, they often involve NAT instead of an actual dedicated VPS, they don't care about HTTPS for webadmin, they run the server as admin/root, and a whole lot of other problems. So in case you're as pedantic as I am, you may be interested in this brand new guide I compiled for you guys, coz I'd like to see a lot more properly set up servers in my server list.

Dedicated Killing Floor 2 Server on Linux

All I want to do is help others - but in case it's against the rules, please don't ban me, just let me know and I'll remove it ASAP. Cheers guys!
 
Code:
sudo -u steam sh -c '~/Steam/steamcmd.sh +login anonymous +force_install_dir ./KF2Server +app_update 232130 validate +exit'

Hmm, you can write this as:

Code:
sudo -u steam ~/Steam/steamcmd.sh +login anonymous +force_install_dir ./KF2Server +app_update 232130 validate +exit

Not a huge fan of hiding the linux stuff behind scripts, people new to Linux might appreciate it if you made it easy for them to debug the entire system.

for example

Code:
sudo systemctl start kf2.service

is very similar to

Code:
sudo systemctl start nginx.service

leading to the user to deduce that this is the common method for running services on linux.

Also add this to your nginx config:

Code:
location /images/ {
    gzip_static on;
    root /path/to/KF2Server/KFGame/Web/;
}

it'll make the loading of the web UI much faster, and reduce load on the actual server, note the gzip_static field is required for the pre-compressed resources to load properly.
 
Upvote 0
Thanks a lot for your responses!

aphocus;n2307485 said:
Not a huge fan of hiding the linux stuff behind scripts

Oh, that was not my intention :) As you can see, I'm explaining a lot of unrelated Linux tech nevertheless. The problem is, systemctl is rather long to type all the type (even with bash autocomplete). On top of that, for sudo roles to be secure, you need to specify full path. So then you compare

Code:
kf2.sh start

with

Code:
sudo /bin/systemctl start kf2.service

Or

Code:
kf2.sh log

with

Code:
sudo /bin/journalctl --system --unit=kf2.service --follow

I think you see the problem :) It's really not to dumb things down, just making them more convenient.

aphocus;n2307485 said:
Also add this to your nginx config:

Code:
location /images/ {
gzip_static on;
root /path/to/KF2Server/KFGame/Web/;
}

it'll make the loading of the web UI much faster, and reduce load on the actual server, note the gzip_static field is required for the pre-compressed resources to load properly.

Uh, could you please elaborate? I just checked gzip_static, it says:

allows sending precompressed files with the ".gz" filename extension instead of regular files.

Are you sure that applies here? I see a few js and json files being pre-compressed, but that doesn't seem like a big deal to me (it might save like a few dozen kBs with an empty cache). Webadmin's always lightning-fast for us (except when it crashes hehe). I even asked my friend who has a 250kbps (yes, you read that right) internet sub, even he said webadmin's fast. Our peak CPU load was around 38% with 1 core on the smallest $5 instance, so I'm not sure load really is a concern at this point either :D I'm just wondering how this could be benchmarked, but when load and wait times are so minuscule, it's probably not worth the hassle.

On the other hand, we could save dozens, if not hundreds of GBs each month if KF2 supported LZMA (or comparable) compressed map downloads. Now that would make a difference, but I'm gonna open a separate thread for that :)
 
Upvote 0
Folks, just published an enormous update both to the installer and the guide. Big additions:
  • Now it uses workshop subscriptions instead of a redirect server, which makes map downloads super fast.
  • It explains file system compression and deduplication, so that you don't have to buy expensive servers with big disks (my instance ATM stores 28G data on 12G disk space and I haven't even run any dedup yet!)
  • It has a mechanism to have a few very small config files which are used to generate the full configuration (makes backups, updates and migrations extremely easy).
  • As a side effect, maps are also really-really easy to add, just enter ID,Name into a csv, issue a command, and you're ready to go.
I haven't yet had the time to test the whole thing out from scratch, but will get to it in the coming weeks and fix any remaining bugs. Cheers.
 
Upvote 0
Sorry for late reply...

bviktor;n2308135 said:
for sudo roles to be secure, you need to specify full path.


I've never heard this before. Could you point me too something referring to this, I've been using Linux since like 2006 and I've never seen this case been made.

To be honest I never put my sudo in scripts to start with, if you have been compromised then the file could be replaced as well, they could steal your password.

On the other side of things do you really type that all that much? I barely touch my server for months, generally only bother to start/stop when I'm pulling in a patch.


bviktor;n2308135 said:
Uh, could you please elaborate? ...

Are you sure that applies here?


The point is to serve the static content outside of the kf2 web server because the kf2 web server is slow for large files (like images), as in the the kf2 webserver was the bottleneck, not the connection.

gzip_static is require merely for compatibility, resources fail to load if that isn't specified as some resources are actually precompressed as .gzip in the directory and no "uncompressed" version exists, as the web server needs to know that requests for "blah.js" are actually in the file "blah.js.gzip", you can manually decompress them if you want to remove that option.

With that being said, Tripwire has bugged the URL requests for images in a recent patch, and now it tries to load files that are in all caps (you'll notice in game the maps are in all-caps too!), which blows up because the nginx & linux are case sensitive, probably easily enough to fix with symlinks and a script of some sort.

Or you could use caching with proxy_pass to make it faster, but I'm not sure if KF2 web server handles TTL properly.

I found this tool for deduplicating the workshop maps https://rmlint.readthedocs.io/en/latest/rmlint.1.html

Code:
$ sudo -u steam rmlint /steam/kf2/KFGame/Cache/ /steam/kf2/Binaries/Win64/steamapps/ -go /steam/dedup.sh -c sh:symlink
$ sudo -u steam /steam/dedup.sh
 
Upvote 0