Skip to content

Commit

Permalink
Enable cgimap for web container and update apache config (#333)
Browse files Browse the repository at this point in the history
* Enable cgimap

* Update production config

* Add parameter to restore backup file

* Update Apache config for cgimap
  • Loading branch information
Rub21 authored Jun 13, 2024
1 parent 63842b9 commit 36df970
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
38 changes: 15 additions & 23 deletions images/web/config/production.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,32 @@
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
# Development mode in case domain is localhost

# ======Redirect to HTTPS
RewriteCond %{HTTP_HOST} !=localhost
RewriteCond %{HTTP_HOST} !=127.0.0.1
# RewriteCond %{HTTPS} off
# RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ======Redirect to wwww osmseed.org
# RewriteCond %{HTTP_HOST} =osmseed.org
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# <Location />
# # For TM, do not use cgimap auth.
# <If "%{HTTP_REFERER} !~ m#https://tasks(-\w+)?\.osmseed\.org/#">
# CGIPassAuth On
# </If>
# </Location>
<Location />
CGIPassAuth On
</Location>

# ======Proxying traffic to CGImap====
# RewriteCond %{REQUEST_URI} ^/api/0\.6/map
# RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
# RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
# RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
# RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
# RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
# RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
# RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
# RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]

# For changeset requests originating from TM, do not use cgimap.
# RewriteCond %{REQUEST_METHOD} ^POST$
# RewriteCond %{HTTP_REFERER} !^https://tasks(-\w+)?\.osmseed\.org/ [NC]
# RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteCond %{REQUEST_URI} ^/api/0\.6/map
RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]

# Relax Apache security settings
<Directory /var/www/public>
Expand Down
20 changes: 10 additions & 10 deletions images/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ while "$flag" = true; do
fi
sleep 2
done &
# time rails i18n:js:export assets:precompile
time rails i18n:js:export assets:precompile
bundle exec rails db:migrate
# /usr/local/bin/openstreetmap-cgimap \
# --port=8000 \
# --daemon \
# --instances=10 \
# --dbname=$POSTGRES_DB \
# --host=$POSTGRES_HOST \
# --username=$POSTGRES_USER \
# --password=$POSTGRES_PASSWORD \
# --logfile log/cgimap.log
/usr/local/bin/openstreetmap-cgimap \
--port=8000 \
--daemon \
--instances=3 \
--dbname=$POSTGRES_DB \
--host=$POSTGRES_HOST \
--username=$POSTGRES_USER \
--password=$POSTGRES_PASSWORD \
--logfile log/cgimap.log
bundle exec rake jobs:work &
apachectl -k start -DFOREGROUND
done
4 changes: 4 additions & 0 deletions osm-seed/templates/web/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ spec:
value: {{ .Values.web.env.API_TIMEOUT | default "30" | quote }}
- name: WEB_TIMEOUT
value: {{ .Values.web.env.WEB_TIMEOUT | default "30" | quote }}
# This parameter is specifically if you want to restore a any backup to db,
# you done need to set this values.yaml in case you don't use
- name: BACKUP_FILE_URL
value: {{ .Values.web.env.BACKUP_FILE_URL | default "none" | quote }}
volumeMounts:
- mountPath: /dev/shm
name: shared-memory
Expand Down

0 comments on commit 36df970

Please sign in to comment.