-
-
Notifications
You must be signed in to change notification settings - Fork 90
Rebase generic off monolithic #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
faa6b39
Rebase generic off monolithic
VibroAxe d77cfdc
Exclude steam server status from caching
VibroAxe 425a75c
Apply suggestions from code review
VibroAxe 2fa012f
Ported CACHE_INDEX_SIZE PR from generic
VibroAxe 5175388
Switch to using proxy_cache_lock_age
VibroAxe 3f5d8c5
Update build hierarchy
VibroAxe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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_MEM_SIZE inactive=200d max_size=CACHE_DISK_SIZE loader_files=1000 loader_sleep=50ms loader_threshold=300ms use_temp_path=off; |
This file contains hidden or 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 hidden or 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 @@ | ||
|
|
||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| server { | ||
| listen 80 reuseport; | ||
|
|
||
| access_log /data/logs/access.log cachelog; | ||
| error_log /data/logs/error.log; | ||
|
|
||
|
|
||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| include /etc/nginx/sites-available/cache.conf.d/*.conf; | ||
| } | ||
This file contains hidden or 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 @@ | ||
| resolver UPSTREAM_DNS ipv6=off; | ||
|
|
||
| location / { | ||
|
|
||
| include /etc/nginx/sites-available/cache.conf.d/root/*.conf; | ||
|
|
||
| } | ||
|
|
||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or 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,5 @@ | ||
|
|
||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # 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 hidden or 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; | ||
| } | ||
VibroAxe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
6 changes: 6 additions & 0 deletions
6
overlay/etc/nginx/sites-available/cache.conf.d/22_wsus_cabs.conf
This file contains hidden or 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; | ||
| } | ||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
4 changes: 4 additions & 0 deletions
4
overlay/etc/nginx/sites-available/cache.conf.d/23_steam_server_status.conf
This file contains hidden or 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; | ||
| } | ||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
6 changes: 6 additions & 0 deletions
6
overlay/etc/nginx/sites-available/cache.conf.d/90_lancache_heartbeat.conf
This file contains hidden or 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 hidden or 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; | ||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
30 changes: 30 additions & 0 deletions
30
overlay/etc/nginx/sites-available/cache.conf.d/root/20_cache.conf
This file contains hidden or 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,30 @@ | ||
| # 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; | ||
| 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
VibroAxe marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 hidden or 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 hidden or 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 hidden or 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 |
This file contains hidden or 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,14 @@ | ||
| #!/bin/sh | ||
| set -e | ||
|
|
||
| # Preprocess UPSTREAM_DNS to allow for multiple resolvers using the same syntax as lancache-dns | ||
| UPSTREAM_DNS="$(echo -n "${UPSTREAM_DNS}" | sed 's/[;]/ /g')" | ||
|
|
||
| echo "worker_processes ${NGINX_WORKER_PROCESSES};" > /etc/nginx/workers.conf | ||
| sed -i "s/^user .*/user ${WEBUSER};/" /etc/nginx/nginx.conf | ||
| sed -i "s/CACHE_MEM_SIZE/${CACHE_MEM_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf | ||
| sed -i "s/CACHE_DISK_SIZE/${CACHE_DISK_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf | ||
| sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/sites-available/cache.conf.d/root/20_cache.conf | ||
| sed -i "s/slice 1m;/slice ${CACHE_SLICE_SIZE};/" /etc/nginx/sites-available/cache.conf.d/root/20_cache.conf | ||
| sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/nginx/sites-available/cache.conf.d/10_root.conf | ||
| sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/nginx/stream-available/10_sni.conf |
This file contains hidden or 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,14 @@ | ||
| #!/bin/bash | ||
| if [ -d "/data/cache/cache" ]; then | ||
| echo "Running fast permissions check" | ||
| ls -l /data/cache/cache | tail --lines=+2 | grep -v ${WEBUSER} > /dev/null | ||
|
|
||
| if [[ $? -eq 0 || "$FORCE_PERMS_CHECK" == "true" ]]; then | ||
| echo "Doing full checking of permissions (This WILL take a long time on large caches)..." | ||
| find /data \! -user ${WEBUSER} -exec chown ${WEBUSER}:${WEBUSER} '{}' + | ||
| echo "Permissions ok" | ||
| else | ||
| echo "Fast permissions check successful, if you have any permissions error try running with -e FORCE_PERMS_CHECK = true" | ||
| fi | ||
|
|
||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.