From 051aee9f163ba3e12bb6fee296bade868495d5e8 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 14 Oct 2021 09:47:26 +1100 Subject: [PATCH] ptgbot: have apache cache backend The static server in the ptgbot container is very simple; it will be much better to have apache caching the files which essentially never change. Change-Id: I8056d8c529c60f4b95aaca549528b6aa8465fa78 --- playbooks/roles/ptgbot/tasks/main.yaml | 11 +++++++++++ .../roles/ptgbot/templates/ptgbot.vhost.config.j2 | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/playbooks/roles/ptgbot/tasks/main.yaml b/playbooks/roles/ptgbot/tasks/main.yaml index f17be21188..27a21dcbbd 100644 --- a/playbooks/roles/ptgbot/tasks/main.yaml +++ b/playbooks/roles/ptgbot/tasks/main.yaml @@ -63,6 +63,9 @@ state: present name: "{{ item }}" loop: + - cache + - cache_disk + - cache_socache - rewrite - proxy - proxy_http @@ -70,6 +73,14 @@ - headers - proxy_wstunnel +- name: Ensure apache cache dir + file: + state: directory + path: '/var/cache/apache2/proxy' + owner: root + group: root + mode: 0755 + - name: Copy apache config template: src: ptgbot.vhost.config.j2 diff --git a/playbooks/roles/ptgbot/templates/ptgbot.vhost.config.j2 b/playbooks/roles/ptgbot/templates/ptgbot.vhost.config.j2 index ed20d2376d..1cb17e4e5b 100644 --- a/playbooks/roles/ptgbot/templates/ptgbot.vhost.config.j2 +++ b/playbooks/roles/ptgbot/templates/ptgbot.vhost.config.j2 @@ -42,6 +42,18 @@ SSLCertificateKeyFile /etc/letsencrypt-certs/ptg.opendev.org/ptg.opendev.org.key SSLCertificateChainFile /etc/letsencrypt-certs/ptg.opendev.org/ca.cer + # Enable SHM backend + CacheSocache shmcb + # disk fallback + CacheRoot "/var/cache/apache2/proxy" + # required to match on rewrites + CacheQuickHandler off + # don't pass requests to backend + CacheIgnoreCacheControl On + + CacheEnable socache / + CacheEnable disk / + ProxyPass / http://localhost:8000/ retry=0 ProxyPassReverse / http://localhost:8000/