Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-6374 patch tilejson files to contain proper tiles URL #259

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 50 additions & 90 deletions common.conf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ location /map/v2/ {
}

location /map/v3/ {
# TODO use /map/v3/
rewrite /map/v3/(.*) /map/v2/$1 break;
proxy_pass http://hsl-map-server:8080;
proxy_cache tiles;
Expand All @@ -58,174 +59,133 @@ location /map/v3/ {
add_header X-Cache-Status $upstream_cache_status;
}

location /map/v3/hsl/fi/ {
rewrite /map/v3/hsl/fi/(.*) /otp/routers/hsl/vectorTiles/$1 break;
location ~ ^/map/v3/hsl/(.*)/tilejson.json$ {
rewrite /map/v3/hsl/([^\/]*)/(.*) /otp/routers/hsl/vectorTiles/$2 break;
proxy_pass http://opentripplanner-hsl-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "fi";
add_header Cache-Control "no-cache, no-store, must-revalidate";
sub_filter "https://$host/otp/routers/hsl/vectorTiles/$vector_layers/{z}/{x}/{y}.pbf" "CDN_BASE_URL/map/v3/hsl/$map_lang/$vector_layers/{z}/{x}/{y}.pbf$subscription_key_param";
sub_filter_types *;
}

location /map/v3/hsl/sv/ {
rewrite /map/v3/hsl/sv/(.*) /otp/routers/hsl/vectorTiles/$1 break;
location /map/v3/hsl/ {
rewrite /map/v3/hsl/([^\/]*)/(.*) /otp/routers/hsl/vectorTiles/$2 break;
proxy_pass http://opentripplanner-hsl-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "sv";
}

location /map/v3/hsl/en/ {
rewrite /map/v3/hsl/en/(.*) /otp/routers/hsl/vectorTiles/$1 break;
proxy_pass http://opentripplanner-hsl-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "en";
proxy_set_header Accept-Language $1;
}

location /map/v3/hsl/ticket-sales-map/ {
#TODO use v3 or remove this location
rewrite /map/v3/hsl/ticket-sales-map/(.*) /map/v2/hsl-ticket-sales-map/$1 break;
proxy_pass http://hsl-map-server:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /map/v3/waltti/fi/ {
rewrite /map/v3/waltti/fi/(.*) /otp/routers/waltti/vectorTiles/$1 break;
proxy_pass http://opentripplanner-waltti-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "fi";
}

location /map/v3/waltti/sv/ {
rewrite /map/v3/waltti/sv/(.*) /otp/routers/waltti/vectorTiles/$1 break;
location ~ ^/map/v3/waltti/(.*)/tilejson.json$ {
rewrite /map/v3/waltti/([^\/]*)/(.*) /otp/routers/waltti/vectorTiles/$2 break;
proxy_pass http://opentripplanner-waltti-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "sv";
add_header Cache-Control "no-cache, no-store, must-revalidate";
sub_filter "https://$host/otp/routers/waltti/vectorTiles/$vector_layers/{z}/{x}/{y}.pbf" "CDN_BASE_URL/map/v3/waltti/$map_lang/$vector_layers/{z}/{x}/{y}.pbf$subscription_key_param";
sub_filter_types *;
}

location /map/v3/waltti/en/ {
rewrite /map/v3/waltti/en/(.*) /otp/routers/waltti/vectorTiles/$1 break;
location /map/v3/waltti/ {
rewrite /map/v3/waltti/([^\/]*)/(.*) /otp/routers/waltti/vectorTiles/$2 break;
proxy_pass http://opentripplanner-waltti-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "en";
}

location /map/v3/finland/fi/ {
rewrite /map/v3/finland/fi/(.*) /otp/routers/finland/vectorTiles/$1 break;
proxy_pass http://opentripplanner-finland-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "fi";
proxy_set_header Accept-Language $1;
}

location /map/v3/finland/sv/ {
rewrite /map/v3/finland/sv/(.*) /otp/routers/finland/vectorTiles/$1 break;
location ~ ^/map/v3/finland/(.*)/tilejson.json$ {
rewrite /map/v3/finland/([^\/]*)/(.*) /otp/routers/finland/vectorTiles/$2 break;
proxy_pass http://opentripplanner-finland-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "sv";
add_header Cache-Control "no-cache, no-store, must-revalidate";
sub_filter "https://$host/otp/routers/finland/vectorTiles/$vector_layers/{z}/{x}/{y}.pbf" "CDN_BASE_URL/map/v3/finland/$map_lang/$vector_layers/{z}/{x}/{y}.pbf$subscription_key_param";
sub_filter_types *;
}

location /map/v3/finland/en/ {
rewrite /map/v3/finland/en/(.*) /otp/routers/finland/vectorTiles/$1 break;
location /map/v3/finland/ {
rewrite /map/v3/finland/([^\/]*)/(.*) /otp/routers/finland/vectorTiles/$2 break;
proxy_pass http://opentripplanner-finland-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "en";
proxy_set_header Accept-Language $1;
}

location /map/v3/waltti-alt/fi/ {
rewrite /map/v3/waltti-alt/fi/(.*) /otp/routers/waltti-alt/vectorTiles/$1 break;
location ~ ^/map/v3/waltti-alt/(.*)/tilejson.json$ {
rewrite /map/v3/waltti-alt/([^\/]*)/(.*) /otp/routers/waltti-alt/vectorTiles/$2 break;
proxy_pass http://opentripplanner-waltti-alt-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "fi";
add_header Cache-Control "no-cache, no-store, must-revalidate";
sub_filter "https://$host/otp/routers/waltti-alt/vectorTiles/$vector_layers/{z}/{x}/{y}.pbf" "CDN_BASE_URL/map/v3/waltti-alt/$map_lang/$vector_layers/{z}/{x}/{y}.pbf$subscription_key_param";
sub_filter_types *;
}

location /map/v3/waltti-alt/sv/ {
rewrite /map/v3/waltti-alt/sv/(.*) /otp/routers/waltti-alt/vectorTiles/$1 break;
location /map/v3/waltti-alt/ {
rewrite /map/v3/waltti-alt/([^\/]*)/(.*) /otp/routers/waltti-alt/vectorTiles/$2 break;
proxy_pass http://opentripplanner-waltti-alt-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "sv";
proxy_set_header Accept-Language $1;
}

location /map/v3/waltti-alt/en/ {
rewrite /map/v3/waltti-alt/en/(.*) /otp/routers/waltti-alt/vectorTiles/$1 break;
proxy_pass http://opentripplanner-waltti-alt-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "en";
}

location /map/v3/varely/fi/ {
rewrite /map/v3/varely/fi/(.*) /otp/routers/varely/vectorTiles/$1 break;
proxy_pass http://opentripplanner-varely-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "fi";
}

location /map/v3/varely/sv/ {
rewrite /map/v3/varely/sv/(.*) /otp/routers/varely/vectorTiles/$1 break;
location ~ ^/map/v3/varely/(.*)/tilejson.json$ {
rewrite /map/v3/varely/([^\/]*)/(.*) /otp/routers/varely/vectorTiles/$2 break;
proxy_pass http://opentripplanner-varely-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "sv";
add_header Cache-Control "no-cache, no-store, must-revalidate";
sub_filter "https://$host/otp/routers/varely/vectorTiles/$vector_layers/{z}/{x}/{y}.pbf" "CDN_BASE_URL/map/v3/varely/$map_lang/$vector_layers/{z}/{x}/{y}.pbf$subscription_key_param";
sub_filter_types *;
}

location /map/v3/varely/en/ {
rewrite /map/v3/varely/en/(.*) /otp/routers/varely/vectorTiles/$1 break;
location /map/v3/varely/ {
rewrite /map/v3/varely/([^\/]*)/(.*) /otp/routers/varely/vectorTiles/$2 break;
proxy_pass http://opentripplanner-varely-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "en";
}

location /map/v3-kela/kela/fi/ {
rewrite /map/v3-kela/kela/fi/(.*) /otp/routers/kela/vectorTiles/$1 break;
proxy_pass http://opentripplanner-kela-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "fi";
proxy_set_header Accept-Language $1;
}

location /map/v3-kela/kela/sv/ {
rewrite /map/v3-kela/kela/sv/(.*) /otp/routers/kela/vectorTiles/$1 break;
location ~ ^/map/v3-kela/kela/(.*)/tilejson.json$ {
rewrite /map/v3-kela/kela/([^\/]*)/(.*) /otp/routers/kela/vectorTiles/$2 break;
proxy_pass http://opentripplanner-kela-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "sv";
add_header Cache-Control "no-cache, no-store, must-revalidate";
sub_filter "https://$host/otp/routers/kela/vectorTiles/$vector_layers/{z}/{x}/{y}.pbf" "CDN_BASE_URL/map/v3-kela/kela/$map_lang/$vector_layers/{z}/{x}/{y}.pbf$subscription_key_param";
sub_filter_types *;
}

location /map/v3-kela/kela/en/ {
rewrite /map/v3-kela/kela/en/(.*) /otp/routers/kela/vectorTiles/$1 break;
location /map/v3-kela/kela/ {
rewrite /map/v3-kela/kela/([^\/]*)/(.*) /otp/routers/kela/vectorTiles/$2 break;
proxy_pass http://opentripplanner-kela-v2:8080;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Language "en";
proxy_set_header Accept-Language $1;
}

location /graphiql/ {
Expand Down
14 changes: 1 addition & 13 deletions external.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ location /out/helsinki-fi.smoove.pro/ {
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
}

#turku smoove citybike api (http://data.foli.fi/citybike/smoove)
#turku smoove realtime api (http://data.foli.fi/gtfs-rt/reittiopas)
location /out/data.foli.fi/ {
proxy_pass http://data.foli.fi/;
include allowed-ips.conf;
Expand All @@ -22,18 +22,6 @@ location /out/data.foli.fi/ {
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
}

#oulu realtime api (http://92.62.36.215/RTIX/trip-update)
location /out/92.62.36.215/ {
proxy_pass http://92.62.36.215/;
include allowed-ips.conf;
proxy_cache ext_cache;
proxy_cache_valid 200 30s;
proxy_cache_lock on;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
}

#oulu rt (https://oulu.mattersoft.fi/api/gtfsrealtime/v1.0/feed/tripupdate, servicealert and vehicleposition)
location /out/oulu.mattersoft.fi/ {
proxy_pass https://oulu.mattersoft.fi/;
Expand Down
18 changes: 18 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ http {
# to get rid of a warning about server_names_hash building
server_names_hash_bucket_size 128;

# Following maps are needed for patching tilejson tiles urls in map layers
map $args $digitransit_subscription_key {
"~(^|&)digitransit-subscription-key=(?<temp>[^&]+)" $temp;
}

map $digitransit_subscription_key $subscription_key_param {
default ?digitransit-subscription-key=$digitransit_subscription_key;
"" "";
}

map $request_uri $map_lang {
~^/map/v3/(.*)/(.*)/(.*)/(.*) $2;
}

map $request_uri $vector_layers {
~^/map/v3/(.*)/(.*)/(.*)/(.*) $3;
}

server {
listen 8080 default_server;
include external.conf;
Expand Down
6 changes: 2 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/bin/ash

set -e
#workaround for azure DNS issue
if [ -n "$MESOS_CONTAINER_NAME" ]; then
echo "search marathon.l4lb.thisdcos.directory" >> /etc/resolv.conf;
fi

sed -i "s/VILKKU_BASIC_AUTH/${VILKKU_BASIC_AUTH}/" /etc/nginx/external.conf
sed -i "s/JOJO_BASIC_AUTH/${JOJO_BASIC_AUTH}/" /etc/nginx/external.conf
sed -i "s/LAPPEENRANTA_BASIC_AUTH/${LAPPEENRANTA_BASIC_AUTH}/" /etc/nginx/external.conf
Expand Down Expand Up @@ -33,6 +30,7 @@ sed -i "s/PORI_RT_BASIC_AUTH/${PORI_RT_BASIC_AUTH}/" /etc/nginx/external.conf
sed -i "s/MH_BASIC_AUTH/${MH_BASIC_AUTH}/" /etc/nginx/external.conf
sed -i "s/NYSSE_BASIC_AUTH/${NYSSE_BASIC_AUTH}/" /etc/nginx/external.conf
sed -i "s/WALTTI_TEST_STATIC_BASIC_AUTH/${WALTTI_TEST_STATIC_BASIC_AUTH}/" /etc/nginx/external.conf
sed -i "s#CDN_BASE_URL#${CDN_BASE_URL}#" /etc/nginx/common.conf

#set basic auth
htpasswd -c -B -b .htpasswd $WALTTI_TEST_CREDENTIALS_USER $WALTTI_TEST_CREDENTIALS_PASS &>/dev/null
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ describe('api.digitransit.fi', function() {
testProxying('api.digitransit.fi','/map/v3/hsl/ticket-sales-map/','hsl-map-server:8080');
testProxying('api.digitransit.fi','/map/v3/hsl/en/rental-stations/','opentripplanner-hsl-v2:8080');
testProxying('api.digitransit.fi','/map/v3/waltti/en/rental-stations/','opentripplanner-waltti-v2:8080');
testProxying('api.digitransit.fi','/map/v3/hsl/fi/stops,stations/tilejson.json','opentripplanner-hsl-v2:8080');
testProxying('api.digitransit.fi','/map/v3/finland/en/rental-stations/','opentripplanner-finland-v2:8080');
testProxying('api.digitransit.fi','/map/v3/varely/en/stops,stations/','opentripplanner-varely-v2:8080');
testProxying('api.digitransit.fi','/map/v3/waltti-alt/en/rental-stations/','opentripplanner-waltti-alt-v2:8080');
Expand Down Expand Up @@ -315,8 +316,7 @@ describe('otp debug', function() {
describe('ext-proxy', function() {
this.timeout(5000);
testCaching(null,'/out/helsinki-fi.smoove.pro/api-public/stations',false);
testCaching(null,'/out/data.foli.fi/citybike/smoove',false);
testCaching(null,'/out/92.62.36.215/RTIX/trip-updates',false);
testCaching(null,'/out/data.foli.fi/gtfs-rt/reittiopas',false);
testCaching(null,'/out/stables.donkey.bike/api/public/gbfs/2/donkey_lappeenranta/en/station_status.json',false);
});

Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CONTAINER_ID=$(docker run -d -p 9000:8080 $ADDHOSTS -e VILKKU_BASIC_AUTH="\"test
-e RAUMA_RT_BASIC_AUTH="\"test\"" -e RAUMA_STATIC_BASIC_AUTH="\"test\"" \
-e PORI_RT_BASIC_AUTH="\"test\"" -e MH_BASIC_AUTH="\"test\"" -e RAASEPORI_RT_BASIC_AUTH="\"test\"" \
-e WALTTI_TEST_CREDENTIALS_USER="test" -e WALTTI_TEST_CREDENTIALS_PASS="test" -e WALTTI_TEST_STATIC_BASIC_AUTH="\"test\"" \
-e CDN_BASE_URL="test" \
hsldevcom/digitransit-proxy:integrationtest)

curl -v http://127.0.0.1:9000
Expand Down
Loading