Skip to content

Commit

Permalink
Redirect to cgimap service
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Sep 14, 2023
1 parent c289cff commit 559c37a
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions images/web/config/production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
<IfModule mod_headers.c>
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"
</IfModule>

# 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)$
Expand Down

0 comments on commit 559c37a

Please sign in to comment.