Skip to content

Commit 5ac1473

Browse files
committed
Switch OSM proxy from lighttpd to nginx
Signed-off-by: Cy Rossignol <[email protected]>
1 parent 8f90b53 commit 5ac1473

File tree

4 files changed

+71
-5
lines changed

4 files changed

+71
-5
lines changed

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ services:
105105
- traefik.http.services.osm-log-proxy.loadbalancer.server.port=80
106106

107107
osm-web:
108-
image: rtsp/lighttpd:latest
108+
image: nginx:stable-alpine
109109
depends_on:
110110
- osm-rails
111111
- osm-cgimap
112112
volumes:
113-
- ./osm-web/lighttpd.conf:/etc/lighttpd/conf.d/06-osm.conf:ro
114-
- ./osm-rails/public:/var/www/html:ro
113+
- ./osm-web/nginx.conf:/etc/nginx/conf.d/default.conf:ro
114+
- ./osm-rails/public:/usr/share/nginx/html:ro
115115
labels:
116116
- traefik.enable=true
117117
- traefik.http.routers.osm-web.rule=Host(`${WS_OSM_HOST}`)

osm-web/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
FROM rtsp/lighttpd:latest
1+
FROM nginx:stable-alpine
22

3-
COPY lighttpd.conf /etc/lighttpd/conf.d/06-osm.conf
3+
COPY nginx.conf /etc/nginx/conf.d/default.conf

osm-web/lighttpd.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# This file is based on openstreetmap-cgimap's lighttpd configuration example:
33
# https://github.com/zerebubuth/openstreetmap-cgimap/blob/master/lighttpd.conf
44
#
5+
# We don't use lighttpd anymore. We'll keep this reference file for now. Nginx
6+
# replaced lighttpd, and a similar configuration exists in nginx.conf.
7+
#
58

69
server.reject-expect-100-with-417 = "disable"
710

osm-web/nginx.conf

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
# This file is based on openstreetmap-cgimap's lighttpd configuration example:
3+
# https://github.com/zerebubuth/openstreetmap-cgimap/blob/master/lighttpd.conf
4+
#
5+
6+
# Resolve hostnames with Docker's internal DNS resolver:
7+
resolver 127.0.0.11 ipv6=off;
8+
9+
upstream osm-rails-upstream {
10+
keepalive 4;
11+
server osm-rails:3000;
12+
}
13+
14+
server {
15+
listen 80;
16+
server_name _;
17+
18+
set_real_ip_from 0.0.0.0/0;
19+
real_ip_header X-Forwarded-For;
20+
21+
error_page 404 /dispatch.map;
22+
23+
location / {
24+
if ($request_method = GET) {
25+
rewrite ^/api/0\.6/map(\.(json|xml))?(\?(.*))?$ /dispatch.map break;
26+
rewrite ^/api/0\.6/(node|way|relation)/[0-9]+(\.(json|xml))?$ /dispatch.map break;
27+
rewrite ^/api/0\.6/(node|way|relation)/[0-9]+/history.*$ /dispatch.map break;
28+
rewrite ^/api/0\.6/(node|way|relation)/[0-9]+/[0-9]+.*$ /dispatch.map break;
29+
rewrite ^/api/0\.6/(node|way|relation)/[0-9]+/relations$ /dispatch.map break;
30+
rewrite ^/api/0\.6/node/[0-9]+/ways$ /dispatch.map break;
31+
rewrite ^/api/0\.6/(way|relation)/[0-9]+/full$ /dispatch.map break;
32+
rewrite ^/api/0\.6/changeset/[0-9]+.*$ /dispatch.map break;
33+
rewrite ^/api/0\.6/(nodes|ways|relations)(\?(.*))?$ /dispatch.map break;
34+
rewrite ^/api/0\.6/changeset/[0-9]+/download$ /dispatch.map break;
35+
}
36+
37+
if ($request_method = POST) {
38+
rewrite ^/api/0\.6/changeset/[0-9]+/upload.*$ /dispatch.map break;
39+
}
40+
41+
if ($request_method = PUT) {
42+
rewrite ^/api/0\.6/changeset/[0-9]+/close.*$ /dispatch.map break;
43+
rewrite ^/api/0\.6/changeset/[0-9]+$ /dispatch.map break;
44+
rewrite ^/api/0\.6/changeset/create.*$ /dispatch.map break;
45+
}
46+
47+
location ~ ^/(?!(dispatch\.map)) {
48+
proxy_pass http://osm-rails-upstream;
49+
proxy_set_header Host $host;
50+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
51+
proxy_set_header X-Forwarded-Proto $scheme;
52+
proxy_set_header X-Real-IP $remote_addr;
53+
proxy_set_header X-Remote-User $remote_user;
54+
}
55+
}
56+
57+
location ~ \.map$ {
58+
fastcgi_pass osm-cgimap:8000;
59+
include fastcgi_params;
60+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
61+
fastcgi_param CONNECT_TIMEOUT 0;
62+
}
63+
}

0 commit comments

Comments
 (0)