From 4c36197876c77518da9bd2a06da5da4e02893371 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 27 May 2017 23:21:24 +0200 Subject: [PATCH] Route png requests to Elixir app and cache it good --- docker-compose.yml | 1 + docker/nginx/asciinema.conf | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c8434e8..69b106e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,3 +62,4 @@ services: - ./uploads:/app/uploads - ./log:/app/log - /tmp/asciinema-web:/tmp + - ./volumes/cache:/cache diff --git a/docker/nginx/asciinema.conf b/docker/nginx/asciinema.conf index 702f571..49ac393 100644 --- a/docker/nginx/asciinema.conf +++ b/docker/nginx/asciinema.conf @@ -10,6 +10,9 @@ upstream clj-server { server 127.0.0.1:5000 fail_timeout=0; } +proxy_cache_path /cache levels=1:2 keys_zone=png_cache:10m max_size=10g + inactive=14d use_temp_path=off; + server { listen 80 default_server; listen [::]:80 default_server; @@ -25,7 +28,19 @@ server { } location ~ ^/a/[^.]+\.png$ { - try_files $uri $uri/index.html $uri.html @clj; + proxy_cache png_cache; + proxy_cache_revalidate on; + proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; + proxy_cache_lock on; + proxy_cache_key $uri; + proxy_ignore_headers Set-Cookie; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_pass http://phoenix-server; + proxy_redirect off; } location ~ ^/a/[^.]+\.(json|gif)$ {