mirror of
https://github.com/lancachenet/monolithic
synced 2024-11-22 03:53:06 +00:00
Completed refactor of upstream proxy
Refactored upstream proxy into lancache standard structure. Simplified both location blocks into a single file rather than further delegated folders
This commit is contained in:
parent
0026cdabf3
commit
a27bb4d77c
10 changed files with 47 additions and 25 deletions
|
@ -34,7 +34,7 @@ RUN rm /etc/nginx/sites-enabled/* /etc/nginx/stream-enabled/* ;\
|
|||
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/sites-available/upstream.conf /etc/nginx/sites-enabled/upstream.conf; \
|
||||
ln -s /etc/nginx/sites-available/20_upstream.conf /etc/nginx/sites-enabled/20_upstream.conf; \
|
||||
ln -s /etc/nginx/stream-available/10_sni.conf /etc/nginx/stream-enabled/10_sni.conf
|
||||
|
||||
RUN mkdir -m 755 -p /data/cachedomains ;\
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Primary monolithic cache engine
|
||||
|
||||
server {
|
||||
listen 80 reuseport;
|
||||
|
||||
|
|
17
overlay/etc/nginx/sites-available/20_upstream.conf
Normal file
17
overlay/etc/nginx/sites-available/20_upstream.conf
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Upstream server to proxy and handle inconsistent 302 redirects
|
||||
# All cache traffic is passed through this proxy to allow rewriting of redirects without caching
|
||||
|
||||
# This is particularly important for sony / ps5 as upstreams redirect between them which confuses slice map on caching
|
||||
|
||||
server {
|
||||
|
||||
# Internal bind on 3128, this should not be externally mapped
|
||||
listen localhost:3128 reuseport;
|
||||
|
||||
# No access_log tracking as all requests to this instance are already logged through monolithic
|
||||
|
||||
# access_log /data/logs/upstream-access.log cachelog;
|
||||
error_log /data/logs/upstream-error.log;
|
||||
|
||||
include /etc/nginx/sites-available/upstream.conf.d/*.conf;
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
# Upstream Configuration
|
||||
proxy_next_upstream error timeout http_404;
|
||||
# proxy_pass http://$host$request_uri;
|
||||
|
||||
# Proxy into the redirect handler
|
||||
proxy_pass http://127.0.0.1:3128$request_uri;
|
||||
|
||||
proxy_redirect off;
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
server {
|
||||
listen 3128 reuseport;
|
||||
|
||||
set $orig_loc 'upstream';
|
||||
|
||||
# access_log /data/logs/upstream-access.log cachelog;
|
||||
error_log /data/logs/upstream-error.log;
|
||||
|
||||
resolver UPSTREAM_DNS ipv6=off;
|
||||
|
||||
location / {
|
||||
proxy_pass http://$host$request_uri;
|
||||
proxy_intercept_errors on;
|
||||
error_page 301 302 307 = @upstream_redirect;
|
||||
}
|
||||
|
||||
location @upstream_redirect {
|
||||
set $saved_upstream_location '$upstream_http_location';
|
||||
set $orig_loc 'upstream-302';
|
||||
|
||||
proxy_pass $saved_upstream_location;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
resolver UPSTREAM_DNS ipv6=off;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
# Header to track if resolved from upstream or 302 redirect
|
||||
set $orig_loc 'upstream';
|
|
@ -0,0 +1,9 @@
|
|||
# Proxy all requests to upstream
|
||||
location / {
|
||||
# Simple proxy the request
|
||||
proxy_pass http://$host$request_uri;
|
||||
|
||||
# Catch the errors to process the redirects
|
||||
proxy_intercept_errors on;
|
||||
error_page 301 302 307 = @upstream_redirect;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
# Special location block to handle 302 redirects
|
||||
location @upstream_redirect {
|
||||
# Upstream_http_location contains the Location: redirection from the upstream server
|
||||
set $saved_upstream_location '$upstream_http_location';
|
||||
|
||||
# Set debug header
|
||||
set $orig_loc 'upstream-302';
|
||||
|
||||
# Pass to proxy and reproxy the request
|
||||
proxy_pass $saved_upstream_location;
|
||||
}
|
|
@ -17,5 +17,5 @@ sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/conf.d/20_proxy_cache_path
|
|||
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/sites-available/upstream.conf.d/10_resolver.conf
|
||||
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/nginx/stream-available/10_sni.conf
|
||||
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/nginx/sites-available/upstream.conf
|
||||
|
|
Loading…
Reference in a new issue