Multi-Server Fast Download (FastDL) with sv_downloadurl and apache

In optimizing the running of the three primary SGC Clan servers, I have done some experiments with fast download on my apache server.

A dua is a cached client-side lua file with a checksum-type flat filename that is used for sending to clients when they connect. They are created automatically when you start your server in the srcds/orangebox/garrysmod/cache/dua folder.

My achieved goals:
[ul]
[li]OPTIMIZATION: All servers share uploaded maps, materials and models.
[/li][li]SEGREGATION: Servers have separate dua cache folders.
[/li][li]SIMPLICITY: Transparent fast dl folder structure.
[/li][li]SECURITY: No other servers can download from our fast dl.
[/li][li]MAINTENANCE: Solution to quickly and easily update our cache from the servers.
[/li][/ul]

Current problems:
[ul]
[li]Cannot bz2 the dua files, they don’t seem to work consistantly.
[/li][li]If you change or add a clientside lua and don’t update your fastdl cache, the update won’t be distributed.
[/li][/ul]

Our fast download is located at: http://gmod.sgc-clan.com/
Please note that you cannot download our content but you can see our layout.

In the server.cfg of our servers, we place this:



sv_downloadurl "http://gmod.sgc-clan.com"


In the .htaccess of our apache server, we place this:



# Send all files with the proper MIME type for the Source engine
AddType application/x-srcds .dua .vtf .vmt .bsp

RewriteEngine on

# Restrict downloading resources to clan servers

RewriteCond %{REQUEST_FILENAME} \.(dua|bz2|vmt|vtf|bsp|mdl)$
RewriteCond %{HTTP_REFERER} !^hl2\:\/\/69\.9\.43\.108\:27015$
RewriteCond %{HTTP_REFERER} !^hl2\:\/\/69\.12\.96\.52\:27018$
RewriteCond %{HTTP_REFERER} !^hl2\:\/\/69\.12\.96\.18\:27017$
RewriteRule ^.* - [F,L]

# Redirect the cache for server #1

RewriteCond %{HTTP_REFERER} ^hl2\:\/\/69\.9\.43\.108\:27015$
RewriteCond %{REQUEST_URI} !^\/cache\/dua\/[0-9]$
RewriteCond %{REQUEST_URI} !^\/cache\/dua\/[0-9]\/
RewriteRule ^cache/dua(.*)$ /cache/dua/1$1 [L]

# Redirect the cache for server #2

RewriteCond %{HTTP_REFERER} ^hl2\:\/\/69\.12\.96\.52\:27018$
RewriteCond %{REQUEST_URI} !^\/cache\/dua\/[0-9]$
RewriteCond %{REQUEST_URI} !^\/cache\/dua\/[0-9]\/
RewriteRule ^cache/dua(.*)$ /cache/dua/2$1 [L]

# Redirect the cache for server #3

RewriteCond %{HTTP_REFERER} ^hl2\:\/\/69\.12\.96\.18\:27017$
RewriteCond %{REQUEST_URI} !^\/cache\/dua\/[0-9]$
RewriteCond %{REQUEST_URI} !^\/cache\/dua\/[0-9]\/
RewriteRule ^cache/dua(.*)$ /cache/dua/3$1 [L]


Note: ! means NOT, ^ means beginning, $ means end, * means * in all cases (aka escaping characters), (.*) means “place everything in variable $1”

Because many characters have special meanings, you have to escape them with a backslash, so “hl2://##.##” becomes “hl2://##.##”. We have three servers, hence the three hl2://#.#.#.#:####.

In our folder, we separated the cache folders so we have: /cache/dua/1/.dua, /cache/dua/2/.dua and /cache/dua/3/.dua but the server will only use /cache/dua/.dua and get redirected automatically depending on the server.

I then created a php file that will connect to our server via FTP and download the dua files. It uses AJAX to monitor the process. You can see the interface to it at http://gmod.sgc-clan.com/dua_update.php. If you’d like to see my php code, email me at narkaleptic at mainelan dot net. It works in Chrome, Safari, Opera and FireFox but does NOT work in Internet Explorer due to limitations with Ajax. It will still work, just not update the output properly.

This doesn’t consistently work.

See here for any hope of progress:
0001592: sv_downloadurl not consistently transfering dua files

I have accomplished most of your goals by a different means. If you are still looking for help, contact me at PowerKrewServers@gmail.com

I tryed it like this

Options +Indexes

//
SetEnvIfNoCase Referer hl2://85.25.118.184\ allow_download

Order Deny,Allow

Allowfrom env=allow_download

Deny from all

but it dont work <.<