From patchwork Thu Jun 23 11:45:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 40265 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5769E27BBEA; Thu, 23 Jun 2022 12:46:48 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 13B3227BBE9 for ; Thu, 23 Jun 2022 12:46:48 +0100 (BST) Received: from localhost ([::1]:42560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4LIM-0003gr-UE for patchwork@mira.cbaines.net; Thu, 23 Jun 2022 07:46:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4LHe-0003fQ-Nx for guix-patches@gnu.org; Thu, 23 Jun 2022 07:46:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4LHe-0003ZC-FW for guix-patches@gnu.org; Thu, 23 Jun 2022 07:46:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o4LHe-0008Un-90 for guix-patches@gnu.org; Thu, 23 Jun 2022 07:46:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#56164] [PATCH] services: nginx: Add support for extra content in upstream blocks. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 23 Jun 2022 11:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56164 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 56164@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165598471132593 (code B ref -1); Thu, 23 Jun 2022 11:46:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jun 2022 11:45:11 +0000 Received: from localhost ([127.0.0.1]:37632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4LGp-0008Tc-EW for submit@debbugs.gnu.org; Thu, 23 Jun 2022 07:45:11 -0400 Received: from lists.gnu.org ([209.51.188.17]:49706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4LGm-0008TQ-JY for submit@debbugs.gnu.org; Thu, 23 Jun 2022 07:45:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4LGm-0003OX-8C for guix-patches@gnu.org; Thu, 23 Jun 2022 07:45:08 -0400 Received: from mira.cbaines.net ([212.71.252.8]:36420) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4LGh-0003Dl-Ov for guix-patches@gnu.org; Thu, 23 Jun 2022 07:45:06 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id 9C17C27BBE9 for ; Thu, 23 Jun 2022 12:45:01 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 86010773 for ; Thu, 23 Jun 2022 11:45:00 +0000 (UTC) From: Christopher Baines Date: Thu, 23 Jun 2022 12:45:00 +0100 Message-Id: <20220623114500.13409-1-mail@cbaines.net> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches I'm looking at this as I'd like to use the keepalive functionality. * gnu/services/web.scm (nginx-upstream-configuration-extra-content): New procedure. (emit-nginx-upstream-config): Include the extra-content if applicable. * doc/guix.texi (NGINX): Document this. --- doc/guix.texi | 3 +++ gnu/services/web.scm | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index bbb7d0764d..0a96ad1852 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -28490,6 +28490,9 @@ prefix @samp{unix:}. For addresses using an IP address or domain name, the default port is 80, and a different port can be specified explicitly. +@item @code{extra-content} +A string or list of strings to add to the upstream block. + @end table @end deftp diff --git a/gnu/services/web.scm b/gnu/services/web.scm index 4f06d4e0bb..4434fecf02 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -120,6 +120,7 @@ (define-module (gnu services web) nginx-upstream-configuration? nginx-upstream-configuration-name nginx-upstream-configuration-servers + nginx-upstream-configuration-extra-content nginx-location-configuration nginx-location-configuration? @@ -517,7 +518,9 @@ (define-record-type* nginx-upstream-configuration make-nginx-upstream-configuration nginx-upstream-configuration? (name nginx-upstream-configuration-name) - (servers nginx-upstream-configuration-servers)) + (servers nginx-upstream-configuration-servers) + (extra-content nginx-upstream-configuration-extra-content + (default '()))) (define-record-type* nginx-location-configuration make-nginx-location-configuration @@ -643,6 +646,15 @@ (define (emit-nginx-upstream-config upstream) (map (lambda (server) (simple-format #f " server ~A;\n" server)) (nginx-upstream-configuration-servers upstream)) + (let ((extra-content + (nginx-upstream-configuration-extra-content upstream))) + (if (and extra-content (not (null? extra-content))) + (cons + "\n" + (map (lambda (line) + (simple-format #f " ~A\n" line)) + (flatten extra-content))) + '())) " }\n")) (define (flatten . lst)