-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from lancachenet/switcheroo
Rebasing generic off monolithic Includes lancachenet/generic#103 lancachenet/generic#93 lancachenet/generic#113 lancachenet/generic#108 Thanks to @Crabbey @zerotacg @csm10495 and @Candunc
- Loading branch information
Showing
31 changed files
with
392 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
FROM lancachenet/generic:latest | ||
MAINTAINER LanCache.Net Team <[email protected]> | ||
FROM lancachenet/ubuntu-nginx:latest | ||
LABEL version=3 | ||
LABEL description="Single caching container for caching game content at LAN parties." | ||
LABEL maintainer="LanCache.Net Team <[email protected]>" | ||
|
||
ENV GENERICCACHE_VERSION=2 \ | ||
CACHE_MODE=monolithic \ | ||
WEBUSER=www-data \ | ||
CACHE_MEM_SIZE=500m \ | ||
CACHE_INDEX_SIZE=500m \ | ||
CACHE_DISK_SIZE=1000000m \ | ||
CACHE_MAX_AGE=3560d \ | ||
CACHE_SLICE_SIZE=1m \ | ||
|
@@ -17,6 +19,20 @@ ENV GENERICCACHE_VERSION=2 \ | |
|
||
COPY overlay/ / | ||
|
||
RUN rm /etc/nginx/sites-enabled/* /etc/nginx/stream-enabled/* ;\ | ||
rm /etc/nginx/conf.d/gzip.conf ;\ | ||
chmod 754 /var/log/tallylog ; \ | ||
id -u ${WEBUSER} &> /dev/null || adduser --system --home /var/www/ --no-create-home --shell /bin/false --group --disabled-login ${WEBUSER} ;\ | ||
chmod 755 /scripts/* ;\ | ||
mkdir -m 755 -p /data/cache ;\ | ||
mkdir -m 755 -p /data/info ;\ | ||
mkdir -m 755 -p /data/logs ;\ | ||
mkdir -m 755 -p /tmp/nginx/ ;\ | ||
chown -R ${WEBUSER}:${WEBUSER} /data/ ;\ | ||
mkdir -p /etc/nginx/sites-enabled ;\ | ||
ln -s /etc/nginx/sites-available/10_cache.conf /etc/nginx/sites-enabled/10_generic.conf; \ | ||
ln -s /etc/nginx/stream-available/10_sni.conf /etc/nginx/stream-enabled/10_sni.conf | ||
|
||
RUN mkdir -m 755 -p /data/cachedomains ;\ | ||
mkdir -m 755 -p /tmp/nginx ;\ | ||
apt-get update ;\ | ||
|
@@ -26,5 +42,5 @@ RUN git clone --depth=1 --no-single-branch https://github.com/uklans/cache-domai | |
|
||
VOLUME ["/data/logs", "/data/cache", "/data/cachedomains", "/var/www"] | ||
|
||
EXPOSE 80 | ||
EXPOSE 80 443 | ||
WORKDIR /scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
proxy_cache_path /data/cache/cache levels=2:2 keys_zone=generic:CACHE_INDEX_SIZE inactive=200d max_size=CACHE_DISK_SIZE loader_files=1000 loader_sleep=50ms loader_threshold=300ms use_temp_path=off; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
user www-data; | ||
include /etc/nginx/workers.conf; | ||
pid /run/nginx.pid; | ||
|
||
include /etc/nginx/modules-enabled/*.conf; | ||
|
||
events { | ||
worker_connections 4096; | ||
multi_accept on; | ||
use epoll; | ||
} | ||
|
||
http { | ||
aio threads; | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
|
||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
|
||
gzip on; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
|
||
include /etc/nginx/sites-enabled/*.conf; | ||
} | ||
|
||
|
||
stream { | ||
include /etc/nginx/stream.d/*.conf; | ||
include /etc/nginx/stream-enabled/*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
server { | ||
listen 80 reuseport; | ||
|
||
access_log /data/logs/access.log cachelog; | ||
error_log /data/logs/error.log; | ||
|
||
include /etc/nginx/sites-available/cache.conf.d/*.conf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resolver UPSTREAM_DNS ipv6=off; | ||
|
||
location / { | ||
|
||
include /etc/nginx/sites-available/cache.conf.d/root/*.conf; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Fix for League of Legends Updater | ||
location ~ ^.+(releaselisting_.*|.version$) { | ||
proxy_pass http://$host; | ||
} |
6 changes: 6 additions & 0 deletions
6
overlay/etc/nginx/sites-available/cache.conf.d/21_arenanet_manifest.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Fix for GW2 manifest | ||
location ^~ /latest64 { | ||
proxy_cache_bypass 1; | ||
proxy_no_cache 1; | ||
proxy_pass http://$host$request_uri; | ||
} |
6 changes: 6 additions & 0 deletions
6
overlay/etc/nginx/sites-available/cache.conf.d/22_wsus_cabs.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Fix for WSUS authroot cab files | ||
location ~* (authrootstl.cab|pinrulesstl.cab|disallowedcertstl.cab)$ { | ||
proxy_cache_bypass 1; | ||
proxy_no_cache 1; | ||
proxy_pass http://$host$request_uri; | ||
} |
4 changes: 4 additions & 0 deletions
4
overlay/etc/nginx/sites-available/cache.conf.d/23_steam_server_status.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
location = /server-status { | ||
proxy_no_cache 1; | ||
proxy_cache_bypass 1; | ||
} |
6 changes: 6 additions & 0 deletions
6
overlay/etc/nginx/sites-available/cache.conf.d/90_lancache_heartbeat.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
location = /lancache-heartbeat { | ||
add_header X-LanCache-Processed-By $hostname; | ||
add_header 'Access-Control-Expose-Headers' '*'; | ||
add_header 'Access-Control-Allow-Origin' '*'; | ||
return 204; | ||
} |
7 changes: 7 additions & 0 deletions
7
overlay/etc/nginx/sites-available/cache.conf.d/root/10_loop_detection.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Abort any circular requests | ||
if ($http_X_LanCache_Processed_By = $hostname) { | ||
return 508; | ||
} | ||
|
||
proxy_set_header X-LanCache-Processed-By $hostname; | ||
add_header X-LanCache-Processed-By $hostname,$http_X_LanCache_Processed_By; |
35 changes: 35 additions & 0 deletions
35
overlay/etc/nginx/sites-available/cache.conf.d/root/20_cache.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Cache Location | ||
slice 1m; | ||
proxy_cache generic; | ||
|
||
proxy_ignore_headers Expires Cache-Control; | ||
proxy_cache_valid 200 206 CACHE_MAX_AGE; | ||
proxy_set_header Range $slice_range; | ||
|
||
# Only download one copy at a time and use a large timeout so | ||
# this really happens, otherwise we end up wasting bandwith | ||
# getting the file multiple times. | ||
proxy_cache_lock on; | ||
# If it's taken over a minute to download a 1m file, we are probably stuck! | ||
# Allow the next request to cache | ||
proxy_cache_lock_age 2m; | ||
# If it's totally broken after an hour, stick it in bypass (this shouldn't ever trigger) | ||
proxy_cache_lock_timeout 1h; | ||
|
||
# Allow the use of state entries | ||
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; | ||
|
||
# Allow caching of 200 but not 301 or 302 as our cache key may not include query params | ||
# hence may not be valid for all users | ||
proxy_cache_valid 301 302 0; | ||
|
||
# Enable cache revalidation | ||
proxy_cache_revalidate on; | ||
|
||
# Don't cache requests marked as nocache=1 | ||
proxy_cache_bypass $arg_nocache; | ||
|
||
# 40G max file | ||
proxy_max_temp_file_size 40960m; | ||
|
||
|
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
overlay/etc/nginx/sites-available/cache.conf.d/root/40_etags.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Battle.net Fix | ||
proxy_hide_header ETag; | ||
|
10 changes: 10 additions & 0 deletions
10
overlay/etc/nginx/sites-available/cache.conf.d/root/90_upstream.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Upstream Configuration | ||
proxy_next_upstream error timeout http_404; | ||
proxy_pass http://$host$request_uri; | ||
proxy_redirect off; | ||
proxy_ignore_client_abort on; | ||
|
||
# Upstream request headers | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
4 changes: 4 additions & 0 deletions
4
overlay/etc/nginx/sites-available/cache.conf.d/root/99_debug_header.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Debug Headers | ||
add_header X-Upstream-Status $upstream_status; | ||
add_header X-Upstream-Response-Time $upstream_response_time; | ||
add_header X-Upstream-Cache-Status $upstream_cache_status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
server { | ||
listen 443; | ||
resolver UPSTREAM_DNS ipv6=off; | ||
proxy_pass $ssl_preread_server_name:443; | ||
ssl_preread on; | ||
|
||
access_log /data/logs/stream-access.log stream_basic; | ||
error_log /data/logs/stream-error.log; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
worker_processes 16; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[program:heartbeat] | ||
command=/scripts/heartbeat.sh | ||
stdout_events_enabled=true | ||
stderr_events_enabled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
echo "Checking cache configuration" | ||
|
||
|
||
print_confighash_warning () { | ||
echo "" | ||
echo "ABORTING STARTUP TO AVOID POTENTIALLY INVALIDATING THE CACHE" | ||
echo "" | ||
echo "If you are happy that this cache is valid with the current config changes" | ||
echo "please delete \`/<cache_mount>/CONFIGHASH\`" | ||
echo "" | ||
echo "See: https://lancache.net/docs/advanced/config-hash/ for more details" | ||
|
||
} | ||
|
||
DETECTED_CACHE_KEY=`grep proxy_cache_key /etc/nginx/sites-available/cache.conf.d/root/30_cache_key.conf | awk '{print $2}'` | ||
NEWHASH="GENERICCACHE_VERSION=${GENERICCACHE_VERSION};CACHE_MODE=${CACHE_MODE};CACHE_SLICE_SIZE=${CACHE_SLICE_SIZE};CACHE_KEY=${DETECTED_CACHE_KEY}" | ||
|
||
if [ -d /data/cache/cache ]; then | ||
echo " Detected existing cache data, checking config hash for consistency" | ||
if [ -f /data/cache/CONFIGHASH ]; then | ||
OLDHASH=`cat /data/cache/CONFIGHASH` | ||
if [ ${OLDHASH} != ${NEWHASH} ]; then | ||
echo "ERROR: Detected CONFIGHASH does not match current CONFIGHASH" | ||
echo " Detected: ${OLDHASH}" | ||
echo " Current: ${NEWHASH}" | ||
print_confighash_warning ${NEWHASH} | ||
exit -1; | ||
else | ||
echo " CONFIGHASH matches current configuration" | ||
fi | ||
else | ||
echo " Could not find CONFIGHASH for existing cachedata" | ||
echo " This is either an upgrade from an older instance of Lancache" | ||
echo " or CONFIGHASH has been deleted intentionally" | ||
echo "" | ||
echo " Creating CONFIGHASH from current live configuration" | ||
echo " Current: ${NEWHASH}" | ||
echo "" | ||
echo " See: https://lancache.net/docs/advanced/config-hash/ for more details" | ||
fi | ||
fi | ||
|
||
mkdir -p /data/cache/cache | ||
echo ${NEWHASH} > /data/cache/CONFIGHASH |
Oops, something went wrong.