Skip to content

Commit c7bc31c

Browse files
committed
Update configs for the website
1 parent b189d32 commit c7bc31c

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

images/web/config/production.conf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,31 @@
22
# ServerName localhost
33
# Tell Apache and Passenger where your app's 'public' directory is
44
DocumentRoot /var/www/public
5+
PassengerAppEnv production
56
PassengerRuby /usr/local/bin/ruby
67
RewriteEngine On
78

8-
# Redirect HTTP to HTTPS for current domain (except localhost)
9+
# Redirect to HTTPS
10+
RewriteCond %{HTTP:X-Forwarded-Proto} =http
911
RewriteCond %{HTTP_HOST} !=localhost
1012
RewriteCond %{HTTP_HOST} !=127.0.0.1
1113
RewriteCond %{HTTPS} off
12-
RewriteCond %{HTTP:X-Forwarded-Proto} !https
1314
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
1415

16+
# Redirect to www
17+
RewriteCond %{HTTP_HOST} =SERVER_DOMAIN_PLACEHOLDER
18+
RewriteCond %{HTTP_HOST} !^www\. [NC]
19+
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
20+
1521
<Location />
1622
CGIPassAuth On
1723
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
1824
</Location>
1925

20-
# Proxying traffic to CGImap
26+
#Proxying traffic to CGImap
2127
ProxyTimeout 1200
2228
RewriteCond %{REQUEST_URI} ^/api/0\.6/map
2329
RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
24-
25-
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
2630
RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
2731
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
2832
RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://${CGIMAP_URL}:${CGIMAP_PORT}$0 [P]
@@ -48,4 +52,12 @@
4852
FcgidIOTimeout 1200
4953
FcgidConnectTimeout 1200
5054
</IfModule>
55+
56+
# Allow CORS for JSON, PBF, and PNG files for map-style
57+
<FilesMatch "\.(json|pbf|png)$">
58+
Header set Access-Control-Allow-Origin "*"
59+
Header set Access-Control-Allow-Methods "GET, OPTIONS"
60+
Header set Access-Control-Allow-Headers "Content-Type"
61+
</FilesMatch>
62+
5163
</VirtualHost>

images/web/config/settings.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ wikimedia_commons_url: "https://commons.wikimedia.org/wiki/"
148148
#github_auth_secret: ""
149149
#microsoft_auth_id: ""
150150
#microsoft_auth_secret: ""
151-
wikipedia_auth_id: ""
152-
wikipedia_auth_secret: ""
151+
# wikipedia_auth_id: ""
152+
# wikipedia_auth_secret: ""
153153
#apple_auth_id: ""
154154
#apple_team_id: ""
155155
#apple_key_id: ""
156156
#apple_private_key: ""
157-
openstreetmap_auth_id: ""
158-
openstreetmap_auth_secret: ""
159-
openstreetmap_auth_scopes: ["read_prefs"]
157+
# openstreetmap_auth_id: ""
158+
# openstreetmap_auth_secret: ""
159+
# openstreetmap_auth_scopes: ["read_prefs"]
160160
# Thunderforest authentication details
161161
#thunderforest_key: ""
162162
# Tracestrack authentication details
@@ -168,10 +168,10 @@ csp_enforce: false
168168
# URL for reporting Content-Security-Policy violations
169169
#csp_report_url: ""
170170
# Storage services to use in production mode
171-
avatar_storage: "local" # TODO: Change to S3
172-
trace_file_storage: "local" # TODO: Change to S3
173-
trace_image_storage: "local" # TODO: Change to S3
174-
trace_icon_storage: "local" # TODO: Change to S3
171+
avatar_storage: "s3" # TODO: Change to S3
172+
trace_file_storage: "s3" # TODO: Change to S3
173+
trace_image_storage: "s3" # TODO: Change to S3
174+
trace_icon_storage: "s3" # TODO: Change to S3
175175
# Root URL for storage services
176176
# avatar_storage_url:
177177
# trace_image_storage_url:

images/web/start.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ EOF
4242
sed -i -e 's/^server_protocol: ".*"/server_protocol: "'$SERVER_PROTOCOL'"/g' $workdir/config/settings.yml
4343
sed -i -e 's/^server_url: ".*"/server_url: "'$SERVER_URL'"/g' $workdir/config/settings.yml
4444

45+
#### Extract domain from SERVER_URL and replace in production.conf
46+
SERVER_DOMAIN=$(echo "$SERVER_URL" | sed -e 's|^[^/]*//||' -e 's|^www\.||' -e 's|/.*$||')
47+
sed -i -e "s/SERVER_DOMAIN_PLACEHOLDER/$SERVER_DOMAIN/g" /etc/apache2/sites-available/production.conf
48+
4549
### Setting up website status
4650
sed -i -e 's/^status: ".*"/status: "'$WEBSITE_STATUS'"/g' $workdir/config/settings.yml
4751

@@ -82,7 +86,7 @@ EOF
8286
export DOORKEEPER_SIGNING_KEY=$(cat /var/www/private.pem | sed -e '1d;$d' | tr -d '\n')
8387
sed -i "s#PRIVATE_KEY#${DOORKEEPER_SIGNING_KEY}#" $workdir/config/settings.yml
8488

85-
sed -i '252s/\(\[\)/&.compact/' "$workdir/app/controllers/application_controller.rb"
89+
# sed -i '252s/\(\[\)/&.compact/' "$workdir/app/controllers/application_controller.rb"
8690

8791
}
8892

0 commit comments

Comments
 (0)