add proxy settings to location config default tip

Thu, 19 Mar 2026 21:00:01 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 19 Mar 2026 21:00:01 +0100
changeset 737
b240ff52cee5
parent 736
f707afcd4218

add proxy settings to location config

src/server/daemon/location.c file | annotate | diff | comparison | revisions
src/server/daemon/location.h file | annotate | diff | comparison | revisions
--- a/src/server/daemon/location.c	Wed Mar 18 21:42:35 2026 +0100
+++ b/src/server/daemon/location.c	Thu Mar 19 21:00:01 2026 +0100
@@ -116,6 +116,26 @@
         if(cxListAdd(location->rewrite, rule)) {
             return 1;
         }
+    } else if(!cx_strcasecmp(name, "ProxyPass")) {
+        location->config.proxy_url = cx_strdup_a(a, dir->args->value);
+        if(!location->config.proxy_url.ptr) {
+            return 1;
+        }
+    } else if(!cx_strcasecmp(name, "ProxyHeader")) {
+        if(!location->config.proxy_headers) {
+            location->config.proxy_headers = cxLinkedListCreate(a, CX_STORE_POINTERS);
+            if(!location->config.proxy_headers) {
+                return 1;
+            }
+        }
+        StringTemplate *header_tpl = string_template_compile(a, cx_strcast(dir->args->value));
+        if(!header_tpl) {
+            return 1;
+        }
+        if(cxListAdd(location->config.proxy_headers, header_tpl)) {
+            string_template_free(header_tpl);
+            return 1;
+        }
     }
     
     return 0;
--- a/src/server/daemon/location.h	Wed Mar 18 21:42:35 2026 +0100
+++ b/src/server/daemon/location.h	Thu Mar 19 21:00:01 2026 +0100
@@ -97,6 +97,17 @@
     cxmutstr docroot;
     
     /*
+     * Reverse proxy url
+     */
+    cxmutstr proxy_url;
+    
+    /*
+     * Reverse proxy header list
+     * Value: StringTemplate*
+     */
+    CxList *proxy_headers;
+    
+    /*
      * Redirect URL
      * Can contain references to regex capture groups (redirect match regex,
      * if available, or the location regex)

mercurial