KF2 Custom Map Redirect with nginx - Epic and Steam Servers
Custom maps are where most home KF2 servers break. Players need a way to download the map when they join, and the public redirect many people used is gone. This guide, based on a community Reddit post, shows how to run your own map redirect with nginx on Windows. It works for the Epic Games Store version as well as Steam.
The author's caveat applies: this is what worked on one setup. Some steps may be unnecessary, and it may not work everywhere.
Reference guides
Two longer guides are worth keeping open:
- the official Tripwire wiki page "Dedicated Server (Killing Floor 2)" - SteamCMD install and the port list
- the Steam guide with ID 1110775580 - especially its "Custom Map Data Store & Map Cycle" section
Installing the server
- SteamCMD - install the server into its own folder, separate from the game, following the official wiki.
- Epic Games version - you can also just run the
KF2Server.batthat ships in the Epic install folder. It sets up a working server, but without WebAdmin (see below).
Forward the ports from the official guide. The NTP port is only needed for Weekly Outbreak. If you cannot forward ports, see the VPN section at the end. For basic setup steps see KF2 dedicated server via SteamCMD.
Configuring and WebAdmin
The author recommends KF2ServerTool for running and configuring the server; it also has a WebAdmin tab built in.
If you set up the server from the Epic install's KF2Server.bat, WebAdmin will not work because its files are missing. Fix it by installing the server once with SteamCMD, then copying ...\kf2server\KFGame\Web with all its contents into your server.
Hosting custom maps with nginx
- Collect your maps. Download the
.kfmfiles you want (for Workshop maps without a Steam copy, see the last section). - Get nginx. Download the Windows build from nginx.org and unpack it.
- Create the map folder. Next to
nginx.exe, create a folder namedkf2and put all.kfmfiles in it. - Configure nginx. Replace the contents of
conf\nginx.confwith:
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80 default_server;
server_name localhost;
access_log <nginx_install_folder>logs/access.log;
error_log <nginx_install_folder>logs/error.log;
root <nginx_install_folder>;
index index.php;
location /kf2 {
autoindex on;
}
}
}
Replace <nginx_install_folder> with the real path and make sure it ends with a forward slash (/).
- Forward port 80 on your router to this PC.
- Test it. Run
nginx.exeand openhttp://localhost/kf2in a browser. You should see a list of your.kfmfiles. nginx has no window; it only shows up as a background process in Task Manager. - Copy the maps to the server into
...\kf2server\KFGame\BrewedPC\Maps. The author put each map in its own subfolder named after the file, though that may not be required. - Set the download manager. Open
...\kf2server\KFGame\Config\PCServer-KFEngine.ini. Under[IpDrv.TcpNetDriver]keep exactly one line:
DownloadManagers=IpDrv.HTTPDownload
Delete any other DownloadManagers= lines.
- Point the redirect at nginx. Under
[IpDrv.HTTPDownload]leave only:
RedirectToURL=http://<external_IPv4>/kf2/
<external_IPv4> is your public IP address.
- Add map entries and the map cycle. In
PCServer-KFGame.inifollow the "Custom Map Data Store & Map Cycle" steps from the Steam guide above. Map names and entries are case sensitive.
Local network gotcha
With the redirect set to the external IP, PCs on the same network as the server usually cannot download the maps. Workaround: temporarily set RedirectToURL to the server's local IPv4, connect from each local PC so it downloads and caches the maps, then change it back to the external IP.
Running and connecting
Start nginx first, then the server (batch file or KF2ServerTool). To join, open the in-game console with ~ and type:
| Where you are | Command |
|---|---|
| Anywhere (ports forwarded) | open <external_IPv4>:7777 |
| Same network as the server | open <internal_IPv4> |
| On the server PC itself | open 127.0.0.1 |
From the comments: if you run the SteamCMD server on the same PC you play on with the Epic version, the server may not appear in the LAN tab, but open <local IP> still works. A server whose ports are not forwarded still shows up on the LAN tab for local players.
Playing without port forwarding
If you cannot forward ports, use a virtual LAN tool so everyone appears to be on one network: Hamachi, Radmin VPN or ZeroTier (the author's choice). Everyone joins the same virtual network, and players connect to the IP that tool assigns to the server PC.
Custom map downloads still depend on port 80 being forwarded for nginx. Without it, players outside your real network cannot fetch the maps, and you will have to share the files another way, for example through a cloud drive.
Downloading a Workshop item without owning the game on Steam
Epic players can still pull Workshop files with SteamCMD:
- Download SteamCMD from Valve's developer wiki.
- Get the app ID from the game's Steam link (for Killing Floor 2 it is
232090). - Get the item ID from the end of the Workshop link.
- In SteamCMD run:
login anonymous
workshop_download_item <AppID> <ModID>
- The files land in
...\steamcmd\steamapps\workshop\content\<AppID>\<ModID>.
Redirect on Apache, IIS or HFS
Notes by w.a.l from the "KF2: redirect for maps, mutators and everything else" thread on the killingfloor.ru forum (2017):
- The redirect URL must not contain a port. At the time of writing KF2 did not understand an address like
http://host:8080/maps/, so the web server has to serve files on the standard port 80. HFS and similar tools on port 80 produce a URL without a colon on their own. - Teach the web server to serve KF2 files. It does not know the
.kfm,.upkand.uextensions and may serve them wrongly without a MIME type. In Apache, add the types tomime.typesor put an.htaccessfile into the redirect folder (in IIS, add a MIME type for each extension):
AddType "map/download" .kfm
AddType "package/download" .upk
AddType "mutator/download" .u
From the "Скачивание карт с сервера" (downloading maps from the server) thread on the killingfloor.ru forum: with RedirectToURL=http://<IP>:8080/<path>/redirect/ in PCServer-KFEngine.ini, the game reported an error opening the file. The advice given:
- create a
mapssubfolder in the redirect folder and put the map there, so the path is.../redirect/maps/(siriushard, linking to the Tripwire forum); - in
[IpDrv.TcpNetDriver]of the same file, checkAllowDownloads=Trueand theDownloadManagers=IpDrv.HTTPDownloadline (RaideN-); - keep in mind that port 8080 is used by WebAdmin by default, and downloads will not work through it (STaJIKeR). The thread author's WebAdmin was on another port.
After these changes it worked for the author, but downloads were very slow.
Linux hosting
A commenter recommends LinuxGSM for KF2 servers on Linux because it handles updates easily. The nginx config looks a little different on Linux, but the redirect idea is the same.
FAQ
- Why use my own redirect instead of the Steam Workshop?
- Workshop downloads only help Steam players and did not work reliably for the author. A web server you control lets Epic and Steam players alike download your .kfm maps when they join.
- Which port does the nginx redirect need?
- Port 80 TCP, forwarded to the PC running nginx, in addition to the normal KF2 server ports.
- Why can't PCs on my own network download the maps?
- RedirectToURL points at your external IP, which local PCs often cannot reach. Temporarily switch it to the local IPv4, download the maps on those PCs, then switch it back.
- Does the Epic Games version include WebAdmin?
- A server started from the Epic install's KF2Server.bat lacks the WebAdmin files. Install the server once with SteamCMD and copy its KFGame\Web folder into your server.