Skip to content

Commit

Permalink
Update RewriteRules for web container
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Sep 12, 2023
1 parent fbb0998 commit 48da869
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions images/web/config/production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,34 @@
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ======Redirect traffic to CGIMAP====
# Rules to redirect to port 81
################### Redirect traffic to CGIMAP Staging ###################
# Redirect to port cgimap staging
RewriteCond %{REQUEST_URI} ^/api/0\.6/map
RewriteRule ^.*$ http://127.0.0.1:81%{REQUEST_URI} [P,L]
RewriteCond %{HTTP_HOST} =staging.openhistoricalmap.org
RewriteRule ^.*$ https://cgimap-staging.openhistoricalmap.org%{REQUEST_URI} [P,L]

# Existing rewrites
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]

# Set CORS headers for any request within openhistoricalmap.org
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"
Header set Access-Control-Expose-Headers "Content-Length,Content-Range"
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]

# 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]

# Relax Apache security settings
<Directory /var/www/public>
Expand Down

0 comments on commit 48da869

Please sign in to comment.