Code Monkey home page Code Monkey logo

Comments (4)

Istador avatar Istador commented on May 19, 2024 5

With docker-compose and nginx this could look like so:

docker-compose.yml:

version: "3.7"

volumes:
  openstreetmap-data:
  openstreetmap-rendered-tiles:

services:

  proxy:
    image: nginx
    volumes:
    - ./nginx.conf:/etc/nginx/conf.d/default.conf
    - ./domain.crt:/etc/nginx/conf.d/domain.crt
    - ./domain.key:/etc/nginx/conf.d/domain.key
    ports:
    - 0.0.0.0:80:80
    - 0.0.0.0:443:443
    depends_on:
    - osm
    restart: always

  osm:
    image: overv/openstreetmap-tile-server
    command: run
    environment:
    - THREADS=24
    volumes:
    - openstreetmap-data:/var/lib/postgresql/10/main
    - openstreetmap-rendered-tiles:/var/lib/mod_tile
    shm_size: 128M
    restart: always

nginx.conf:

server {
  server_name _;

  listen 80 default_server;
  listen 443 ssl default_server;

  ssl_certificate /etc/nginx/conf.d/domain.crt;
  ssl_certificate_key /etc/nginx/conf.d/domain.key;

  location ~ ^/tile/[0-9]+/[0-9]+/[0-9]+.png$ {
    proxy_pass http://osm;
  }
}

Initialization (in the same directory):

# generate certificate and private key
# (normally you want the cert signed by a CA. I'd recommend to use Let's Encrypt instead of this step)
openssl  req  -x509  -nodes  -days 365  -newkey rsa:8192  -keyout domain.key  -out domain.crt

# download PBF file
wget  -O data.osm.pbf  https://download.geofabrik.de/europe/germany/hamburg-latest.osm.pbf

# initializes the database and import the PBF file
docker-compose  run  -v "/`pwd`/data.osm.pbf":/data.osm.pbf  osm  import

# start the services
docker-compose  up  -d

# pre-render all tiles on zoom levels 0 to 5
docker-compose  exec  osm  render_list  -a  -f  -m ajt  -z 0  -Z 5

If you want to use your already existing named volumes that contain your imported database and pre-rendered tiles (from your other issue), you can change the volumes section to the following (and skip the import and pre-render in the Initialization):

volumes:
  openstreetmap-data:
    external: true
  openstreetmap-rendered-tiles:
    external: true

from openstreetmap-tile-server.

Istador avatar Istador commented on May 19, 2024 1

This project uses apache to serve the rendered tiles over HTTP.

Opening the 443 port didn't work for you, because the apache server inside the docker container isn't listening on port 443 to serve HTTPS but only HTTP on port 80.
In order to offer HTTPS by this docker image natively you would need to modify the apache.conf and mount your certificate and your private key into the docker container.

Alternatively you could put a proxy (e.g. traefik, nginx, apache) in-front of the OSM docker container that handles HTTP and HTTPS to the outside, either on your host system or encapsulated in another docker container on your system, that internally forwards the requests to the OSM container on port 80.
That way you don't have to modify the content of the OSM container and it - what I personally prefer - separates the HTTP(S) handling and especially the private key from the OSM container that maintains the postgres database, tile rendering and storage.

from openstreetmap-tile-server.

Overv avatar Overv commented on May 19, 2024 1

Additionally I recommend looking into the Let's Encrypt companion for nginx to simplify HTTPS even more.

from openstreetmap-tile-server.

Rex-Legor avatar Rex-Legor commented on May 19, 2024

this may help someone struggling with this:
in my case it was not enough to use nginx for enabling https, I also needed to configure a proxy this way:
https://www.serverlab.ca/tutorials/containers/docker/how-to-set-the-proxy-for-docker-on-ubuntu/

from openstreetmap-tile-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.