From 68a977a58733df2468c284261d2ae128e573c684 Mon Sep 17 00:00:00 2001
From: Evangelos Foutras <evangelos@foutrelis.com>
Date: Fri, 4 Jun 2021 08:16:10 +0300
Subject: [PATCH] dbscripts: Prevent concurrent mirrorauth requests

- Set "proxy_cache_lock on" to avoid sending more than one auth request
  to archweb when a cache entry doesn't exist for the credentials.
- Set "proxy_cache_use_stale updating" to prevent nginx sending multiple
  auth requests to archweb while the cache is being refreshed. [1]

[1] http://mailman.nginx.org/pipermail/nginx/2016-January/049734.html
---
 roles/dbscripts/templates/nginx.d.conf.j2 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/roles/dbscripts/templates/nginx.d.conf.j2 b/roles/dbscripts/templates/nginx.d.conf.j2
index 00734f17f..771dc27ea 100644
--- a/roles/dbscripts/templates/nginx.d.conf.j2
+++ b/roles/dbscripts/templates/nginx.d.conf.j2
@@ -44,6 +44,10 @@ server {
         proxy_cache             auth_cache;
         proxy_cache_key         $scheme$proxy_host$uri$http_authorization;
 
+        # Minimize the number of requests to archweb
+        proxy_cache_lock        on;
+        proxy_cache_use_stale   updating;
+
         # Authentication to archweb
         proxy_pass https://archlinux.org;
 	proxy_ssl_verify on;
-- 
GitLab