Skip to content

Instantly share code, notes, and snippets.

@toxatoor
Created February 20, 2019 10:36
Show Gist options
  • Save toxatoor/e883b7e1680494d2fde6179b1d107c5f to your computer and use it in GitHub Desktop.
Save toxatoor/e883b7e1680494d2fde6179b1d107c5f to your computer and use it in GitHub Desktop.
Pseudo-cdn
# --------------- cacher ----------------------------------
server {
listen 80 ;
server_name static ;
keepalive_timeout 70;
access_log /dev/null ;
root /serv/web/default ;
gzip on ;
gzip_min_length 1100;
gzip_types text/plain application/xml application/x-javascript text/css ;
proxy_intercept_errors on;
recursive_error_pages on ;
location ~* ^/imgcdn/.+\.(jpg|jpeg|gif|png)$ {
root /srv/cache/cache/progressive/remote.static.cdn ;
expires 30d;
error_page 404 = @fetch ;
}
location @fetch {
internal;
proxy_pass http://127.0.0.1:80$uri;
proxy_set_header Host rotater ;
proxy_store /srv/cache/cache/progressive/remote.static.cdn$uri ;
proxy_store_access user:rw group:rw all:r;
proxy_temp_path /tmp ;
error_page 410 404 = @gone ;
}
location @gone {
internal;
proxy_pass http://127.0.0.1:80$uri ;
proxy_set_header Host imgcdn ;
proxy_temp_path /tmp ;
}
}
# --------------- cacher ----------------------------------
# --------------- rotater ----------------------------------
server {
listen 127.0.0.1:80;
server_name rotater ;
keepalive_timeout 70;
access_log /dev/null ;
root /serv/web/default ;
gzip on ;
gzip_min_length 1100;
gzip_types text/plain application/xml application/x-javascript text/css ;
proxy_intercept_errors on;
recursive_error_pages on ;
location / {
image_filter rotate 180 ;
image_filter_interlace on ;
proxy_pass http://127.0.0.1:80$uri ;
proxy_set_header Host interlacer ;
proxy_temp_path /tmp ;
}
}
# --------------- rotater ----------------------------------
# --------------- interlacer ----------------------------------
server {
listen 127.0.0.1:80;
server_name interlacer ;
keepalive_timeout 70;
access_log /dev/null ;
root /serv/web/default ;
gzip on ;
gzip_min_length 1100;
gzip_types text/plain application/xml application/x-javascript text/css ;
proxy_intercept_errors on;
recursive_error_pages on ;
location / {
image_filter rotate 180 ;
image_filter_interlace on ;
proxy_pass http://127.0.0.1:80$uri ;
proxy_set_header Host storage ;
proxy_temp_path /tmp ;
}
}
# --------------- interlacer ----------------------------------
server {
listen 127.0.0.1:80;
server_name storage ;
keepalive_timeout 70;
access_log /dev/null ;
root /serv/web/default ;
gzip on ;
gzip_min_length 1100;
gzip_types text/plain application/xml application/x-javascript text/css ;
proxy_intercept_errors on;
recursive_error_pages on ;
location ~* ^/imgcdn/.+\.(jpg|jpeg|gif|png)$ {
root /srv/cache/cache/remote/remote.static.cdn ;
expires 30d;
error_page 404 = @fetch ;
}
location @fetch {
internal;
if ( $uri ~* "/imgcdn/(.+)$" ) { set $puri "/images/$1"; }
proxy_pass http://remote.static.cdn:80$puri ;
proxy_set_header Host remote.static.cdn ;
proxy_store /srv/cache/cache/remote/remote.static.cdn$uri ;
proxy_store_access user:rw group:rw all:r;
proxy_temp_path /tmp ;
error_page 410 404 = @gone ;
}
location @gone {
internal;
proxy_pass http://127.0.0.1:80$uri ;
proxy_set_header Host imgcdn ;
proxy_store /srv/cache/cache/remote/remote.static.cdn$uri ;
proxy_store_access user:rw group:rw all:r;
proxy_temp_path /tmp ;
}
}
# --------------- imgcdn ----------------------------------
server {
listen 127.0.0.1:80 ;
server_name imgcdn
keepalive_timeout 70;
access_log /dev/null;
root /srv/storage/storage/cache/remote.static.cdn ;
location / {
expires 2h ;
error_page 410 404 = @gone ;
}
location @gone { empty_gif ; }
}
# --------------- imgcdn ----------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment