From 9dfa2e1cf71309d768bed2d1db4c86b51e449806 Mon Sep 17 00:00:00 2001 From: Rub21 Date: Tue, 12 Sep 2023 20:42:21 -0500 Subject: [PATCH] Fix RewriteRule --- images/web/config/production.conf | 52 ++++++++++--------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/images/web/config/production.conf b/images/web/config/production.conf index df681296..0f2b4e33 100644 --- a/images/web/config/production.conf +++ b/images/web/config/production.conf @@ -1,59 +1,39 @@ # ServerName localhost - # Tell Apache and Passenger where your app's 'public' directory is DocumentRoot /var/www/public PassengerRuby /usr/bin/ruby - RewriteEngine On - - # Development mode in case domain is localhost - # Rewrite to HTTPS RewriteCond %{HTTP:X-Forwarded-Proto} =http + # Development mode in case domain is localhost + # Rewrite to HTTPS RewriteCond %{HTTP_HOST} !=localhost RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] - # Rewrite to www. [NC] is a case-insensitive match RewriteCond %{HTTP_HOST} !=localhost + # Avoid redirect staging sites RewriteCond %{HTTP_HOST} !=staging.openhistoricalmap.org RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] - ################### Redirect traffic to CGIMAP Staging ################### - # Redirect to port cgimap staging + # ======Redirect trafict to CGIMAP==== + # Rules to redirect to port 81 RewriteCond %{REQUEST_URI} ^/api/0\.6/map - RewriteCond %{HTTP_HOST} =staging.openhistoricalmap.org - RewriteRule ^.*$ https://cgimap-staging.openhistoricalmap.org%{REQUEST_URI} [P,L] - - # Existing rewrites - RewriteCond %{HTTP_HOST} =staging.openhistoricalmap.org - RewriteRule ^0\.6/map$ - [L,H=fcgi:cgimap-staging.openhistoricalmap.org] - RewriteRule ^0\.6/(nodes|ways|relations)$ - [L,H=fcgi:cgimap-staging.openhistoricalmap.org] - RewriteRule ^0\.6/(way|relation)/([^/]+)/full$ - [L,H=fcgi:cgimap-staging.openhistoricalmap.org] - - ################### Redirect traffic to CGIMAP Production ################### - # Rules to redirect to cgimap - RewriteCond %{REQUEST_URI} ^/api/0\.6/map - RewriteCond %{HTTP_HOST} =www.openhistoricalmap.org - RewriteRule ^.*$ https://cgimap.openhistoricalmap.org%{REQUEST_URI} [P,L] - + RewriteRule ^.*$ http://127.0.0.1:80%{REQUEST_URI} [P,L] # Existing rewrites - RewriteCond %{HTTP_HOST} =www.openhistoricalmap.org - RewriteRule ^0\.6/map$ - [L,H=fcgi:cgimap.openhistoricalmap.org] - RewriteRule ^0\.6/(nodes|ways|relations)$ - [L,H=fcgi:cgimap.openhistoricalmap.org] - RewriteRule ^0\.6/(way|relation)/([^/]+)/full$ - [L,H=fcgi:cgimap.openhistoricalmap.org] - - ################### Redirect traffic to CGIMAP development ################### - RewriteCond %{HTTP_HOST} =localhost - RewriteRule ^0\.6/map$ http://127.0.0.1:81%{REQUEST_URI} [P,L] - RewriteRule ^0\.6/(node|way|relation)/([^/]+)$ http://127.0.0.1:81%{REQUEST_URI} [P,L] + RewriteRule ^0\.6/map$ - [L,H=fcgi:127.0.0.1:81] + RewriteRule ^0\.6/(nodes|ways|relations)$ - [L,H=fcgi:127.0.0.1:81] + RewriteRule ^0\.6/(way|relation)/([^/]+)/full$ - [L,H=fcgi:127.0.0.1:81] + + # If no match found, fall through to port 80 + RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$ + RewriteRule ^0\.6/(node|way|relation)/([^/]+)$ - [L,H=fcgi:127.0.0.1:80] # Relax Apache security settings - AllowOverride None - Require all granted - # Allow from all - Options -MultiViews + AllowOverride None + Allow from all + Options -MultiViews