From 2480d0dffbe2be69c51faf023332f4b00c92fd7d Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 7 Aug 2022 06:59:23 +0530 Subject: [PATCH] Use nginx to cache responses. --- template/docker-compose.nginx.yml | 14 -------------- template/pipedapi.conf | 5 ++++- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/template/docker-compose.nginx.yml b/template/docker-compose.nginx.yml index 474fd4c..7d86576 100644 --- a/template/docker-compose.nginx.yml +++ b/template/docker-compose.nginx.yml @@ -22,19 +22,6 @@ services: depends_on: - postgres container_name: piped-backend - varnish: - image: varnish:7.0-alpine - restart: unless-stopped - volumes: - - ./config/default.vcl:/etc/varnish/default.vcl:ro - container_name: varnish - depends_on: - - piped - healthcheck: - test: ash -c "wget --no-verbose --tries=1 --spider 127.0.0.1:80/feed || (varnishreload && exit 1)" - interval: 10s - timeout: 10s - retries: 1 nginx: image: nginx:mainline-alpine restart: unless-stopped @@ -50,7 +37,6 @@ services: container_name: nginx depends_on: - piped - - varnish - ytproxy - pipedfrontend postgres: diff --git a/template/pipedapi.conf b/template/pipedapi.conf index da4447d..69db81f 100644 --- a/template/pipedapi.conf +++ b/template/pipedapi.conf @@ -1,10 +1,13 @@ +proxy_cache_path /tmp/pipedapi_cache levels=1:2 keys_zone=pipedapi:4m max_size=2g inactive=60m use_temp_path=off; + server { listen 80; server_name BACKEND_HOSTNAME; - set $backend "http://varnish:80"; + set $backend "http://piped:8080"; location / { + proxy_cache pipedapi; proxy_pass $backend; proxy_http_version 1.1; proxy_set_header Connection "keep-alive";