Skip to content

Commit 451f335

Browse files
committed
Add ALLOW_CORS parameter
1 parent 8744ab2 commit 451f335

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ RUN mkdir /var/lib/mod_tile \
131131
&& mkdir /var/run/renderd \
132132
&& chown renderer /var/run/renderd
133133
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
134-
&& a2enconf mod_tile
134+
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
135+
&& a2enconf mod_tile && a2enconf mod_headers
135136
COPY apache.conf /etc/apache2/sites-available/000-default.conf
136137
COPY leaflet-demo.html /var/www/html/index.html
137138
RUN ln -sf /proc/1/fd/1 /var/log/apache2/access.log \

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ docker run \
7979

8080
This will enable a background process that automatically downloads changes from the OpenStreetMap server, filters them for the relevant region polygon you specified, updates the database and finally marks the affected tiles for rerendering.
8181

82+
### Cross-origin resource sharing
83+
84+
To enable the `Access-Control-Allow-Origin` header to be able to retrieve tiles from other domains, simply set the `ALLOW_CORS` variable to `1`:
85+
86+
```
87+
docker run \
88+
-p 80:80 \
89+
-v openstreetmap-data:/var/lib/postgresql/10/main \
90+
-e ALLOW_CORS=1 \
91+
-d overv/openstreetmap-tile-server \
92+
run
93+
```
94+
8295
## Performance tuning and tweaking
8396

8497
Details for update procedure and invoked scripts can be found here [link](https://ircama.github.io/osm-carto-tutorials/updating-data/).

apache.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010

1111
ErrorLog ${APACHE_LOG_DIR}/error.log
1212
CustomLog ${APACHE_LOG_DIR}/access.log combined
13+
14+
<IfDefine ALLOW_CORS>
15+
Header set Access-Control-Allow-Origin "*"
16+
</IfDefine>
1317
</VirtualHost>

run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ if [ "$1" = "run" ]; then
6969
# Fix postgres data privileges
7070
chown postgres:postgres /var/lib/postgresql -R
7171

72+
# Configure Apache CORS
73+
if [ "$ALLOW_CORS" == "1" ]; then
74+
echo "export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
75+
fi
76+
7277
# Initialize PostgreSQL and Apache
7378
CreatePostgressqlConfig
7479
service postgresql start

0 commit comments

Comments
 (0)