Add ALLOW_CORS parameter

This commit is contained in:
Alexander Overvoorde 2019-08-31 13:44:23 +02:00
parent 8744ab2792
commit 451f335bc5
4 changed files with 24 additions and 1 deletions

View File

@ -131,7 +131,8 @@ RUN mkdir /var/lib/mod_tile \
&& mkdir /var/run/renderd \
&& chown renderer /var/run/renderd
RUN echo "LoadModule tile_module /usr/lib/apache2/modules/mod_tile.so" >> /etc/apache2/conf-available/mod_tile.conf \
&& a2enconf mod_tile
&& echo "LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so" >> /etc/apache2/conf-available/mod_headers.conf \
&& a2enconf mod_tile && a2enconf mod_headers
COPY apache.conf /etc/apache2/sites-available/000-default.conf
COPY leaflet-demo.html /var/www/html/index.html
RUN ln -sf /proc/1/fd/1 /var/log/apache2/access.log \

View File

@ -79,6 +79,19 @@ docker run \
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.
### Cross-origin resource sharing
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`:
```
docker run \
-p 80:80 \
-v openstreetmap-data:/var/lib/postgresql/10/main \
-e ALLOW_CORS=1 \
-d overv/openstreetmap-tile-server \
run
```
## Performance tuning and tweaking
Details for update procedure and invoked scripts can be found here [link](https://ircama.github.io/osm-carto-tutorials/updating-data/).

View File

@ -10,4 +10,8 @@
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfDefine ALLOW_CORS>
Header set Access-Control-Allow-Origin "*"
</IfDefine>
</VirtualHost>

5
run.sh
View File

@ -69,6 +69,11 @@ if [ "$1" = "run" ]; then
# Fix postgres data privileges
chown postgres:postgres /var/lib/postgresql -R
# Configure Apache CORS
if [ "$ALLOW_CORS" == "1" ]; then
echo "export APACHE_ARGUMENTS='-D ALLOW_CORS'" >> /etc/apache2/envvars
fi
# Initialize PostgreSQL and Apache
CreatePostgressqlConfig
service postgresql start