diff --git a/images/web/config/production.conf b/images/web/config/production.conf index 8c918f97..e7cfa04a 100644 --- a/images/web/config/production.conf +++ b/images/web/config/production.conf @@ -3,32 +3,28 @@ # Tell Apache and Passenger where your app's 'public' directory is DocumentRoot /var/www/public PassengerRuby /usr/bin/ruby - - # Add CORS headers for preflight requests - - Header set Access-Control-Allow-Origin "*" - Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" - Header set Access-Control-Max-Age "1000" - Header set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token" - - - # Existing rewrite rules RewriteEngine On 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 + # ======Redirect trafict to CGIMAP==== + # Rules to redirect to port 81 RewriteCond %{REQUEST_URI} ^/api/0\.6/map - RewriteRule ^.*$ 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] + RewriteRule ^.*$ https://cgimap-staging.openhistoricalmap.org%{REQUEST_URI} [P,L] + # Existing rewrites + 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] # If no match found, fall through to port 80 RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$