Skip to content

Commit

Permalink
Add ALLOW_CORS parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Overv committed Aug 31, 2019
1 parent 8744ab2 commit 451f335
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down
4 changes: 4 additions & 0 deletions apache.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 5 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 451f335

Please sign in to comment.