From 954480dfe129a9b411760f9e6aad8fd47a7cc173 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 20 Oct 2021 19:17:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Try=20a=20new=20proxy=20rule=20s?= =?UTF-8?q?etup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/httpd.conf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/proxy/httpd.conf b/proxy/httpd.conf index 3efca55..c6f289b 100644 --- a/proxy/httpd.conf +++ b/proxy/httpd.conf @@ -562,34 +562,34 @@ RewriteEngine on # Preserve host ProxyPreserveHost on +# Let static requests pass through +# static.sophon.steffo.eu → static +RewriteCond "static.%{ENV:APACHE_PROXY_BASE_DOMAIN} %{HTTP_HOST}" "^([^ ]+) \1$" [NC] # If ENV:APACHE_PROXY_BASE_DOMAIN equals HTTP_HOST +RewriteRule ".?" - [L] # Process the request yourself # Proxy regular requests to the frontend # sophon.steffo.eu → frontend -RewriteCond "%{ENV:matched}" "! -eq 1" [NC] # If the url hasn't been matched by the previous rules RewriteCond "%{ENV:APACHE_PROXY_BASE_DOMAIN} %{HTTP_HOST}" "^([^ ]+) \1$" [NC] # If ENV:APACHE_PROXY_BASE_DOMAIN equals HTTP_HOST RewriteCond "%{ENV:SOPHON_FRONTEND_NAME}" "^(.+)$" [NC] # Capture ENV:SOPHON_FRONTEND_NAME for substitution in the rewriterule -RewriteRule "/(.*)" "http://%1/$1" [P,L,E=matched:1] # Rewrite as a SPA and set the matched flag +RewriteRule "/(.*)" "http://%1/$1" [P,L] # Rewrite as a SPA and set the matched flag # Proxy api requests to the backend # api.sophon.steffo.eu → backend -RewriteCond "%{ENV:matched}" "! -eq 1" [NC] # If the url hasn't been matched by the previous rules RewriteCond "api.%{ENV:APACHE_PROXY_BASE_DOMAIN} %{HTTP_HOST}" "^([^ ]+) \1$" [NC] # If api. prefixed to ENV:APACHE_PROXY_BASE_DOMAIN equals HTTP_HOST RewriteCond "%{ENV:SOPHON_BACKEND_NAME}" "^(.+)$" [NC] # Capture ENV:SOPHON_BACKEND_NAME for substitution in the rewriterule -RewriteRule "/(.*)" "http://%1/$1" [P,L,E=matched:1] # Rewrite and set the matched flag +RewriteRule "/(.*)" "http://%1/$1" [P,L] # Rewrite and set the matched flag # Create a map between the proxy file generated by Sophon and Apache RewriteMap "sophonproxy" "dbm=gdbm:/run/sophon/proxy/proxy.dbm" # Proxy websockets to the notebooks # *.sophon.steffo.eu → notebook -RewriteCond "%{ENV:matched}" "! -eq 1" [NC] # If the url hasn't been matched by the previous rules RewriteCond ".%{ENV:APACHE_PROXY_BASE_DOMAIN} %{HTTP_HOST}" "^([^ ]+) [^ ]+\1$" [NC] # If this is any other subdomain of ENV:APACHE_PROXY_BASE_DOMAIN RewriteCond "%{HTTP:Connection}" "Upgrade" [NC] # If this is a websocket connection RewriteCond "%{HTTP:Upgrade}" "websocket" [NC] # If this is a websocket connection -RewriteRule "/(.*)" "ws://${sophonproxy:%{HTTP_HOST}}/$1" [P,L,E=matched:1] # Rewrite and set the matched flag +RewriteRule "/(.*)" "ws://${sophonproxy:%{HTTP_HOST}}/$1" [P,L] # Rewrite and set the matched flag # Proxy regular requests to the notebooks # *.sophon.steffo.eu → notebook -RewriteCond "%{ENV:matched}" "! -eq 1" [NC] # If the url hasn't been matched by the previous rules RewriteCond ".%{ENV:APACHE_PROXY_BASE_DOMAIN} %{HTTP_HOST}" "^([^ ]+) [^ ]+\1$" [NC] # If this is any other subdomain of ENV:APACHE_PROXY_BASE_DOMAIN -RewriteRule "/(.*)" "http://${sophonproxy:%{HTTP_HOST}}/$1" [P,L,E=matched:1] +RewriteRule "/(.*)" "http://${sophonproxy:%{HTTP_HOST}}/$1" [P,L]