Merge remote-tracking branch 'upstream/master' into remove_ie_support

This commit is contained in:
acalcutt 2023-02-19 14:10:12 -05:00
commit 56e4aa8e69
15 changed files with 748 additions and 648 deletions

View file

@ -60,7 +60,7 @@ jobs:
uses: docker/setup-buildx-action@v2
- name: Test Docker Build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
push: false

View file

@ -80,7 +80,7 @@ jobs:
password: ${{ github.event.inputs.docker_token }}
- name: Build and publish Full Version to Docker Hub
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
push: true
@ -106,7 +106,7 @@ jobs:
NPM_TOKEN: ${{ github.event.inputs.npm_token }}
- name: Build and publish Light Version to Docker Hub
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: ./light
file: ./light/Dockerfile

View file

@ -41,11 +41,13 @@ RUN wget -qO- https://deb.nodesource.com/setup_18.x | bash; \
rm -rf /var/lib/apt/lists/*;
RUN mkdir -p /usr/src/app
COPY package* /usr/src/app
WORKDIR /usr/src/app
RUN npm install --omit=dev
COPY package.json /usr/src/app
COPY package-lock.json /usr/src/app
RUN npm ci --omit=dev
FROM ubuntu:focal AS final

View file

@ -974,3 +974,32 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
===========================================================================
Leaflet - BSD 2-Clause License
Copyright (c) 2010-2023, Volodymyr Agafonkin
Copyright (c) 2010-2011, CloudMade
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1,35 +1,9 @@
#!/bin/sh
set -e
handle() {
SIGNAL=$(( $? - 128 ))
echo "Caught signal ${SIGNAL}, stopping gracefully"
kill -s ${SIGNAL} $(pidof node) 2>/dev/null
}
trap handle INT TERM
refresh() {
SIGNAL=$(( $? - 128 ))
echo "Caught signal ${SIGNAL}, refreshing"
kill -s ${SIGNAL} $(pidof node) 2>/dev/null
}
trap refresh HUP
if ! which -- "${1}"; then
# first arg is not an executable
xvfb-run -a --server-args="-screen 0 1024x768x24" -- node /usr/src/app/ "$@" &
# Wait exits immediately on signals which have traps set. Store return value and wait
# again for all jobs to actually complete before continuing.
wait $! || RETVAL=$?
while [ ${RETVAL} = 129 ] ; do
# Refressh signal HUP received. Continue waiting for signals.
wait $! || RETVAL=$?
done
wait
exit ${RETVAL}
export DISPLAY=:99
Xvfb "${DISPLAY}" -nolisten unix &
exec node /usr/src/app/ "$@"
fi
exec "$@"

View file

@ -1,35 +1,7 @@
#!/bin/sh
set -e
handle() {
SIGNAL=$(( $? - 128 ))
echo "Caught signal ${SIGNAL}, stopping gracefully"
kill -s ${SIGNAL} $(pidof node) 2>/dev/null
}
trap handle INT TERM
refresh() {
SIGNAL=$(( $? - 128 ))
echo "Caught signal ${SIGNAL}, refreshing"
kill -s ${SIGNAL} $(pidof node) 2>/dev/null
}
trap refresh HUP
if ! which -- "${1}"; then
# first arg is not an executable
node /usr/src/app/ "$@" &
# Wait exits immediately on signals which have traps set. Store return value and wait
# again for all jobs to actually complete before continuing.
wait $! || RETVAL=$?
while [ ${RETVAL} = 129 ] ; do
# Refressh signal HUP received. Continue waiting for signals.
wait $! || RETVAL=$?
done
wait
exit ${RETVAL}
exec node /usr/src/app/ "$@"
fi
exec "$@"

View file

@ -9,6 +9,58 @@ Caching
There is a plenty of options you can use to create proper caching infrastructure: Varnish, CloudFlare, ...
Cloudflare Cache Rules
-----------
Cloudflare supports custom rules for configuring caching:
https://developers.cloudflare.com/cache/about/cache-rules/
tileserver-gl renders tiles in multiple formats - ``.png``, ``.jpg (jpeg)``, ``.webp`` for the raster endpoints, ``.pbf`` for vector endpoint. In addition, style information is generated with ``.json`` format.
Endpoint data can be configured to be cached by Cloudflare. For example to cache vector endpoint you will need to configure Cloudflare rules for the ``.pbf`` and ``.json`` data.
Create a rule which matches ``hostname (equal)`` and ``URI Path (ends with)`` for ``.pbf`` and ``.json`` fields. Set cache status to eligible for cache to enable the caching and overwrite the ``Edge TTL`` with ``Browser TTL`` to be 7 days (depends on your application usage).
This will ensure that Cloudflare will cache your tiles on Cloudflare side for seven days aswell on the client side. If the tileserver is down or user has no internet access it will try to use cached tiles from Cloudflare or local.
Note that ``Browser TTL`` will overwrite expiration dates on the client device. If you rebuild your maps, old tiles will be rendered until it expires or cache is cleared on the client device.
Nginx Cache
-----------
If you have a reverse proxy setup in front of the tileserver you may want to enable caching as it will greatly offload requests from the application.
Configure the proxy cache path directive to initialize your cache store:
::
proxy_cache_path /var/cache/nginx/tileserver
keys_zone=TileserverCache:50m
levels=1:2
inactive=2w
max_size=10g;
Make sure to give proper permissions for the /var/cache/nginx/tileserver folder. Usually nginx is running with www-data user.
Enable caching on specific proxy pass:
::
location / {
include proxy_params;
proxy_pass http://127.0.0.1:8080/;
proxy_cache TileserverCache;
proxy_cache_valid 200 1w;
# add_header X-Cache-Status $upstream_cache_status;
}
If you need to confirm whether caching works or not, uncomment the X-Cache-Status header. This will return a header on response with `HIT` or `MISS` header value which indicates if nginx cached the response or not.
Make sure to clean your cache by removing files in the configured directory after you change your styles or tile information. You may experiment with the caching values to fit your needs.
More about Nginx caching: https://docs.nginx.com/nginx/admin-guide/content-cache/content-caching/
Securing
========
@ -18,3 +70,68 @@ Running behind a proxy or a load-balancer
=========================================
If you need to run TileServer GL behind a proxy, make sure the proxy sends ``X-Forwarded-*`` headers to the server (most importantly ``X-Forwarded-Host`` and ``X-Forwarded-Proto``) to ensure the URLs generated inside TileJSON, etc. are using the desired domain and protocol.
Nginx Reverse Proxy
-----------
An example nginx reverse proxy server configuration for HTTPS connections. It enables caching, CORS and Cloudflare Authenticated Pulls.
::
proxy_cache_path /var/cache/nginx/tileserver
keys_zone=TileserverCache:50m
levels=1:2
inactive=2w
max_size=1g;
map_hash_bucket_size 128;
map $http_origin $allow_origin {
https://www.example.com $http_origin;
default "";
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/www.example.com/cert.pem;
ssl_certificate_key /etc/ssl/www.example.com/key.pem;
# https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/
ssl_client_certificate /etc/ssl/cloudflare.pem;
ssl_verify_client on;
server_name www.example.com example.com;
# Disable root application access. You may want to allow this in development.
location ~ ^/$ {
return 404;
}
# Disable root application access. You may want to allow this in development.
location /favicon.ico {
return 404;
}
location / {
# This include directive sets up required headers for proxy and proxy cache.
# Aswell it includes the required ``X-Forwarded-*`` headers for tileserver to propely generate tiles.
include proxy_params;
proxy_pass http://127.0.0.1:8080/;
# Disable default CORS headers
proxy_hide_header Access-Control-Allow-Origin;
# Enable proxy cache
proxy_cache TileserverCache;
proxy_cache_valid 200 1w;
# Set our custom CORS
add_header 'Access-Control-Allow-Origin' $allow_origin;
# If you need to see nginx cache status. Uncomment line below.
# add_header X-Cache-Status $upstream_cache_status;
}
}

273
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "tileserver-gl",
"version": "4.4.2",
"version": "4.4.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tileserver-gl",
"version": "4.4.2",
"version": "4.4.5",
"license": "BSD-2-Clause",
"dependencies": {
"@mapbox/glyph-pbf-composite": "0.0.3",
@ -38,20 +38,20 @@
"tileserver-gl": "src/main.js"
},
"devDependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"chai": "4.3.7",
"eslint": "^8.32.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jsdoc": "^39.6.8",
"eslint-plugin-jsdoc": "^40.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-security": "^1.7.0",
"eslint-plugin-security": "^1.7.1",
"husky": "^8.0.3",
"lint-staged": "^13.1.0",
"lint-staged": "^13.1.2",
"mocha": "^10.2.0",
"prettier": "^2.8.3",
"prettier": "^2.8.4",
"should": "^13.2.3",
"supertest": "^6.3.3",
"yaml-lint": "^1.7.0"
@ -196,16 +196,16 @@
}
},
"node_modules/@commitlint/cli": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.4.2.tgz",
"integrity": "sha512-0rPGJ2O1owhpxMIXL9YJ2CgPkdrFLKZElIZHXDN8L8+qWK1DGH7Q7IelBT1pchXTYTuDlqkOTdh//aTvT3bSUA==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-17.4.4.tgz",
"integrity": "sha512-HwKlD7CPVMVGTAeFZylVNy14Vm5POVY0WxPkZr7EXLC/os0LH/obs6z4HRvJtH/nHCMYBvUBQhGwnufKfTjd5g==",
"dev": true,
"dependencies": {
"@commitlint/format": "^17.4.0",
"@commitlint/lint": "^17.4.2",
"@commitlint/load": "^17.4.2",
"@commitlint/read": "^17.4.2",
"@commitlint/types": "^17.4.0",
"@commitlint/format": "^17.4.4",
"@commitlint/lint": "^17.4.4",
"@commitlint/load": "^17.4.4",
"@commitlint/read": "^17.4.4",
"@commitlint/types": "^17.4.4",
"execa": "^5.0.0",
"lodash.isfunction": "^3.0.9",
"resolve-from": "5.0.0",
@ -220,9 +220,9 @@
}
},
"node_modules/@commitlint/config-conventional": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.4.2.tgz",
"integrity": "sha512-JVo1moSj5eDMoql159q8zKCU8lkOhQ+b23Vl3LVVrS6PXDLQIELnJ34ChQmFVbBdSSRNAbbXnRDhosFU+wnuHw==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-17.4.4.tgz",
"integrity": "sha512-u6ztvxqzi6NuhrcEDR7a+z0yrh11elY66nRrQIpqsqW6sZmpxYkDLtpRH8jRML+mmxYQ8s4qqF06Q/IQx5aJeQ==",
"dev": true,
"dependencies": {
"conventional-changelog-conventionalcommits": "^5.0.0"
@ -232,12 +232,12 @@
}
},
"node_modules/@commitlint/config-validator": {
"version": "17.4.0",
"resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.4.0.tgz",
"integrity": "sha512-Sa/+8KNpDXz4zT4bVbz2fpFjvgkPO6u2V2fP4TKgt6FjmOw2z3eEX859vtfeaTav/ukBw0/0jr+5ZTZp9zCBhA==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-17.4.4.tgz",
"integrity": "sha512-bi0+TstqMiqoBAQDvdEP4AFh0GaKyLFlPPEObgI29utoKEYoPQTvF0EYqIwYYLEoJYhj5GfMIhPHJkTJhagfeg==",
"dev": true,
"dependencies": {
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"ajv": "^8.11.0"
},
"engines": {
@ -245,12 +245,12 @@
}
},
"node_modules/@commitlint/ensure": {
"version": "17.4.0",
"resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.4.0.tgz",
"integrity": "sha512-7oAxt25je0jeQ/E0O/M8L3ADb1Cvweu/5lc/kYF8g/kXatI0wxGE5La52onnAUAWeWlsuvBNar15WcrmDmr5Mw==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-17.4.4.tgz",
"integrity": "sha512-AHsFCNh8hbhJiuZ2qHv/m59W/GRE9UeOXbkOqxYMNNg9pJ7qELnFcwj5oYpa6vzTSHtPGKf3C2yUFNy1GGHq6g==",
"dev": true,
"dependencies": {
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"lodash.camelcase": "^4.3.0",
"lodash.kebabcase": "^4.1.1",
"lodash.snakecase": "^4.1.1",
@ -271,12 +271,12 @@
}
},
"node_modules/@commitlint/format": {
"version": "17.4.0",
"resolved": "https://registry.npmjs.org/@commitlint/format/-/format-17.4.0.tgz",
"integrity": "sha512-Z2bWAU5+f1YZh9W76c84J8iLIWIvvm+mzqogTz0Nsc1x6EHW0Z2gI38g5HAjB0r0I3ZjR15IDEJKhsxyblcyhA==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/format/-/format-17.4.4.tgz",
"integrity": "sha512-+IS7vpC4Gd/x+uyQPTAt3hXs5NxnkqAZ3aqrHd5Bx/R9skyCAWusNlNbw3InDbAK6j166D9asQM8fnmYIa+CXQ==",
"dev": true,
"dependencies": {
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"chalk": "^4.1.0"
},
"engines": {
@ -284,12 +284,12 @@
}
},
"node_modules/@commitlint/is-ignored": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.4.2.tgz",
"integrity": "sha512-1b2Y2qJ6n7bHG9K6h8S4lBGUl6kc7mMhJN9gy1SQfUZqe92ToDjUTtgNWb6LbzR1X8Cq4SEus4VU8Z/riEa94Q==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-17.4.4.tgz",
"integrity": "sha512-Y3eo1SFJ2JQDik4rWkBC4tlRIxlXEFrRWxcyrzb1PUT2k3kZ/XGNuCDfk/u0bU2/yS0tOA/mTjFsV+C4qyACHw==",
"dev": true,
"dependencies": {
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"semver": "7.3.8"
},
"engines": {
@ -297,30 +297,30 @@
}
},
"node_modules/@commitlint/lint": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.4.2.tgz",
"integrity": "sha512-HcymabrdBhsDMNzIv146+ZPNBPBK5gMNsVH+el2lCagnYgCi/4ixrHooeVyS64Fgce2K26+MC7OQ4vVH8wQWVw==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-17.4.4.tgz",
"integrity": "sha512-qgkCRRFjyhbMDWsti/5jRYVJkgYZj4r+ZmweZObnbYqPUl5UKLWMf9a/ZZisOI4JfiPmRktYRZ2JmqlSvg+ccw==",
"dev": true,
"dependencies": {
"@commitlint/is-ignored": "^17.4.2",
"@commitlint/parse": "^17.4.2",
"@commitlint/rules": "^17.4.2",
"@commitlint/types": "^17.4.0"
"@commitlint/is-ignored": "^17.4.4",
"@commitlint/parse": "^17.4.4",
"@commitlint/rules": "^17.4.4",
"@commitlint/types": "^17.4.4"
},
"engines": {
"node": ">=v14"
}
},
"node_modules/@commitlint/load": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.4.2.tgz",
"integrity": "sha512-Si++F85rJ9t4hw6JcOw1i2h0fdpdFQt0YKwjuK4bk9KhFjyFkRxvR3SB2dPaMs+EwWlDrDBGL+ygip1QD6gmPw==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/load/-/load-17.4.4.tgz",
"integrity": "sha512-z6uFIQ7wfKX5FGBe1AkOF4l/ShOQsaa1ml/nLMkbW7R/xF8galGS7Zh0yHvzVp/srtfS0brC+0bUfQfmpMPFVQ==",
"dev": true,
"dependencies": {
"@commitlint/config-validator": "^17.4.0",
"@commitlint/config-validator": "^17.4.4",
"@commitlint/execute-rule": "^17.4.0",
"@commitlint/resolve-extends": "^17.4.0",
"@commitlint/types": "^17.4.0",
"@commitlint/resolve-extends": "^17.4.4",
"@commitlint/types": "^17.4.4",
"@types/node": "*",
"chalk": "^4.1.0",
"cosmiconfig": "^8.0.0",
@ -346,12 +346,12 @@
}
},
"node_modules/@commitlint/parse": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.4.2.tgz",
"integrity": "sha512-DK4EwqhxfXpyCA+UH8TBRIAXAfmmX4q9QRBz/2h9F9sI91yt6mltTrL6TKURMcjUVmgaB80wgS9QybNIyVBIJA==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.4.4.tgz",
"integrity": "sha512-EKzz4f49d3/OU0Fplog7nwz/lAfXMaDxtriidyGF9PtR+SRbgv4FhsfF310tKxs6EPj8Y+aWWuX3beN5s+yqGg==",
"dev": true,
"dependencies": {
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"conventional-changelog-angular": "^5.0.11",
"conventional-commits-parser": "^3.2.2"
},
@ -360,13 +360,13 @@
}
},
"node_modules/@commitlint/read": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/read/-/read-17.4.2.tgz",
"integrity": "sha512-hasYOdbhEg+W4hi0InmXHxtD/1favB4WdwyFxs1eOy/DvMw6+2IZBmATgGOlqhahsypk4kChhxjAFJAZ2F+JBg==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/read/-/read-17.4.4.tgz",
"integrity": "sha512-B2TvUMJKK+Svzs6eji23WXsRJ8PAD+orI44lVuVNsm5zmI7O8RSGJMvdEZEikiA4Vohfb+HevaPoWZ7PiFZ3zA==",
"dev": true,
"dependencies": {
"@commitlint/top-level": "^17.4.0",
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"fs-extra": "^11.0.0",
"git-raw-commits": "^2.0.0",
"minimist": "^1.2.6"
@ -376,13 +376,13 @@
}
},
"node_modules/@commitlint/resolve-extends": {
"version": "17.4.0",
"resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.4.0.tgz",
"integrity": "sha512-3JsmwkrCzoK8sO22AzLBvNEvC1Pmdn/65RKXzEtQMy6oYMl0Snrq97a5bQQEFETF0VsvbtUuKttLqqgn99OXRQ==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-17.4.4.tgz",
"integrity": "sha512-znXr1S0Rr8adInptHw0JeLgumS11lWbk5xAWFVno+HUFVN45875kUtqjrI6AppmD3JI+4s0uZlqqlkepjJd99A==",
"dev": true,
"dependencies": {
"@commitlint/config-validator": "^17.4.0",
"@commitlint/types": "^17.4.0",
"@commitlint/config-validator": "^17.4.4",
"@commitlint/types": "^17.4.4",
"import-fresh": "^3.0.0",
"lodash.mergewith": "^4.6.2",
"resolve-from": "^5.0.0",
@ -393,15 +393,15 @@
}
},
"node_modules/@commitlint/rules": {
"version": "17.4.2",
"resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.4.2.tgz",
"integrity": "sha512-OGrPsMb9Fx3/bZ64/EzJehY9YDSGWzp81Pj+zJiY+r/NSgJI3nUYdlS37jykNIugzazdEXfMtQ10kmA+Kx2pZQ==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-17.4.4.tgz",
"integrity": "sha512-0tgvXnHi/mVcyR8Y8mjTFZIa/FEQXA4uEutXS/imH2v1UNkYDSEMsK/68wiXRpfW1euSgEdwRkvE1z23+yhNrQ==",
"dev": true,
"dependencies": {
"@commitlint/ensure": "^17.4.0",
"@commitlint/ensure": "^17.4.4",
"@commitlint/message": "^17.4.2",
"@commitlint/to-lines": "^17.4.0",
"@commitlint/types": "^17.4.0",
"@commitlint/types": "^17.4.4",
"execa": "^5.0.0"
},
"engines": {
@ -430,9 +430,9 @@
}
},
"node_modules/@commitlint/types": {
"version": "17.4.0",
"resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.4.0.tgz",
"integrity": "sha512-2NjAnq5IcxY9kXtUeO2Ac0aPpvkuOmwbH/BxIm36XXK5LtWFObWJWjXOA+kcaABMrthjWu6la+FUpyYFMHRvbA==",
"version": "17.4.4",
"resolved": "https://registry.npmjs.org/@commitlint/types/-/types-17.4.4.tgz",
"integrity": "sha512-amRN8tRLYOsxRr6mTnGGGvB5EmW/4DDjLMgiwK3CCVEmN6Sr/6xePGEpWaspKkckILuUORCwe6VfDBw6uj4axQ==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0"
@ -998,9 +998,9 @@
"integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ=="
},
"node_modules/@types/node": {
"version": "18.11.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==",
"version": "18.14.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.0.tgz",
"integrity": "sha512-5EWrvLmglK+imbCJY0+INViFWUHg1AHel1sq4ZVSfdcNqGy9Edv3UB9IIzzg+xPaUcAgZYcfVs2fBcwDeZzU0A==",
"dev": true
},
"node_modules/@types/normalize-package-data": {
@ -1015,15 +1015,16 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.49.0.tgz",
"integrity": "sha512-IhxabIpcf++TBaBa1h7jtOWyon80SXPRLDq0dVz5SLFC/eW6tofkw/O7Ar3lkx5z5U6wzbKDrl2larprp5kk5Q==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.52.0.tgz",
"integrity": "sha512-lHazYdvYVsBokwCdKOppvYJKaJ4S41CgKBcPvyd0xjZNbvQdhn/pnJlGtQksQ/NhInzdaeaSarlBjDXHuclEbg==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.49.0",
"@typescript-eslint/type-utils": "5.49.0",
"@typescript-eslint/utils": "5.49.0",
"@typescript-eslint/scope-manager": "5.52.0",
"@typescript-eslint/type-utils": "5.52.0",
"@typescript-eslint/utils": "5.52.0",
"debug": "^4.3.4",
"grapheme-splitter": "^1.0.4",
"ignore": "^5.2.0",
"natural-compare-lite": "^1.4.0",
"regexpp": "^3.2.0",
@ -1048,14 +1049,14 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.49.0.tgz",
"integrity": "sha512-veDlZN9mUhGqU31Qiv2qEp+XrJj5fgZpJ8PW30sHU+j/8/e5ruAhLaVDAeznS7A7i4ucb/s8IozpDtt9NqCkZg==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.52.0.tgz",
"integrity": "sha512-e2KiLQOZRo4Y0D/b+3y08i3jsekoSkOYStROYmPUnGMEoA0h+k2qOH5H6tcjIc68WDvGwH+PaOrP1XRzLJ6QlA==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.49.0",
"@typescript-eslint/types": "5.49.0",
"@typescript-eslint/typescript-estree": "5.49.0",
"@typescript-eslint/scope-manager": "5.52.0",
"@typescript-eslint/types": "5.52.0",
"@typescript-eslint/typescript-estree": "5.52.0",
"debug": "^4.3.4"
},
"engines": {
@ -1075,13 +1076,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.49.0.tgz",
"integrity": "sha512-clpROBOiMIzpbWNxCe1xDK14uPZh35u4QaZO1GddilEzoCLAEz4szb51rBpdgurs5k2YzPtJeTEN3qVbG+LRUQ==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.52.0.tgz",
"integrity": "sha512-AR7sxxfBKiNV0FWBSARxM8DmNxrwgnYMPwmpkC1Pl1n+eT8/I2NAUPuwDy/FmDcC6F8pBfmOcaxcxRHspgOBMw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.49.0",
"@typescript-eslint/visitor-keys": "5.49.0"
"@typescript-eslint/types": "5.52.0",
"@typescript-eslint/visitor-keys": "5.52.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -1092,13 +1093,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.49.0.tgz",
"integrity": "sha512-eUgLTYq0tR0FGU5g1YHm4rt5H/+V2IPVkP0cBmbhRyEmyGe4XvJ2YJ6sYTmONfjmdMqyMLad7SB8GvblbeESZA==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.52.0.tgz",
"integrity": "sha512-tEKuUHfDOv852QGlpPtB3lHOoig5pyFQN/cUiZtpw99D93nEBjexRLre5sQZlkMoHry/lZr8qDAt2oAHLKA6Jw==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "5.49.0",
"@typescript-eslint/utils": "5.49.0",
"@typescript-eslint/typescript-estree": "5.52.0",
"@typescript-eslint/utils": "5.52.0",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
@ -1119,9 +1120,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.49.0.tgz",
"integrity": "sha512-7If46kusG+sSnEpu0yOz2xFv5nRz158nzEXnJFCGVEHWnuzolXKwrH5Bsf9zsNlOQkyZuk0BZKKoJQI+1JPBBg==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.52.0.tgz",
"integrity": "sha512-oV7XU4CHYfBhk78fS7tkum+/Dpgsfi91IIDy7fjCyq2k6KB63M6gMC0YIvy+iABzmXThCRI6xpCEyVObBdWSDQ==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -1132,13 +1133,13 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.49.0.tgz",
"integrity": "sha512-PBdx+V7deZT/3GjNYPVQv1Nc0U46dAHbIuOG8AZ3on3vuEKiPDwFE/lG1snN2eUB9IhF7EyF7K1hmTcLztNIsA==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.52.0.tgz",
"integrity": "sha512-WeWnjanyEwt6+fVrSR0MYgEpUAuROxuAH516WPjUblIrClzYJj0kBbjdnbQXLpgAN8qbEuGywiQsXUVDiAoEuQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.49.0",
"@typescript-eslint/visitor-keys": "5.49.0",
"@typescript-eslint/types": "5.52.0",
"@typescript-eslint/visitor-keys": "5.52.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -1159,16 +1160,16 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.49.0.tgz",
"integrity": "sha512-cPJue/4Si25FViIb74sHCLtM4nTSBXtLx1d3/QT6mirQ/c65bV8arBEebBJJizfq8W2YyMoPI/WWPFWitmNqnQ==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.52.0.tgz",
"integrity": "sha512-As3lChhrbwWQLNk2HC8Ree96hldKIqk98EYvypd3It8Q1f8d5zWyIoaZEp2va5667M4ZyE7X8UUR+azXrFl+NA==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.49.0",
"@typescript-eslint/types": "5.49.0",
"@typescript-eslint/typescript-estree": "5.49.0",
"@typescript-eslint/scope-manager": "5.52.0",
"@typescript-eslint/types": "5.52.0",
"@typescript-eslint/typescript-estree": "5.52.0",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0",
"semver": "^7.3.7"
@ -1185,12 +1186,12 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.49.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.49.0.tgz",
"integrity": "sha512-v9jBMjpNWyn8B6k/Mjt6VbUS4J1GvUlR4x3Y+ibnP1z7y7V4n0WRz+50DY6+Myj0UaXVSuUlHohO+eZ8IJEnkg==",
"version": "5.52.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.52.0.tgz",
"integrity": "sha512-qMwpw6SU5VHCPr99y274xhbm+PRViK/NATY6qzt+Et7+mThGuFSl/ompj2/hrBlRP/kq+BFdgagnOSgw9TB0eA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.49.0",
"@typescript-eslint/types": "5.52.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
@ -2207,9 +2208,9 @@
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/cookiejar": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz",
"integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==",
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz",
"integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==",
"dev": true
},
"node_modules/core-util-is": {
@ -2695,9 +2696,9 @@
}
},
"node_modules/eslint": {
"version": "8.32.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz",
"integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==",
"version": "8.34.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.34.0.tgz",
"integrity": "sha512-1Z8iFsucw+7kSqXNZVslXS8Ioa4u2KM7GPwuKtkTFAqZ/cHMcEaR+1+Br0wLlot49cNxIiZk5wp8EAbPcYZxTg==",
"dev": true,
"dependencies": {
"@eslint/eslintrc": "^1.4.1",
@ -2763,9 +2764,9 @@
}
},
"node_modules/eslint-plugin-jsdoc": {
"version": "39.6.8",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.6.8.tgz",
"integrity": "sha512-8W2B2vCfqXmV6AxhEO9u25zPqk7V/LxCsZBl0xDF1CSLDqabiQQtZXpWp19K53HMfFZMLeNRJRUFFhauWgMZrA==",
"version": "40.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-40.0.0.tgz",
"integrity": "sha512-LOPyIu1vAVvGPkye3ci0moj0iNf3f8bmin6do2DYDj+77NRXWnkmhKRy8swWsatUs3mB5jYPWPUsFg9pyfEiyA==",
"dev": true,
"dependencies": {
"@es-joy/jsdoccomment": "~0.36.1",
@ -2805,9 +2806,9 @@
}
},
"node_modules/eslint-plugin-security": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-1.7.0.tgz",
"integrity": "sha512-+ahcCh7M5w7fdFaNccaChBGq8nd3Wa+XvGJS+hY74kvrMhG4EuLbljRIjilOqh1iDMW/EckB1oOWmiVIYlVACQ==",
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-security/-/eslint-plugin-security-1.7.1.tgz",
"integrity": "sha512-sMStceig8AFglhhT2LqlU5r+/fn9OwsA72O5bBuQVTssPCdQAOQzL+oMn/ZcpeUY6KcNfLJArgcrsSULNjYYdQ==",
"dev": true,
"dependencies": {
"safe-regex": "^2.1.1"
@ -3941,9 +3942,9 @@
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw=="
},
"node_modules/http-cache-semantics": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz",
"integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
"integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==",
"optional": true
},
"node_modules/http-errors": {
@ -4675,9 +4676,9 @@
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
},
"node_modules/lint-staged": {
"version": "13.1.0",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.1.0.tgz",
"integrity": "sha512-pn/sR8IrcF/T0vpWLilih8jmVouMlxqXxKuAojmbiGX5n/gDnz+abdPptlj0vYnbfE0SQNl3CY/HwtM0+yfOVQ==",
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.1.2.tgz",
"integrity": "sha512-K9b4FPbWkpnupvK3WXZLbgu9pchUJ6N7TtVZjbaPsoizkqFUDkUReUL25xdrCljJs7uLUF3tZ7nVPeo/6lp+6w==",
"dev": true,
"dependencies": {
"cli-truncate": "^3.1.0",
@ -6576,9 +6577,9 @@
}
},
"node_modules/prettier": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz",
"integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==",
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz",
"integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"

View file

@ -1,6 +1,6 @@
{
"name": "tileserver-gl",
"version": "4.4.2",
"version": "4.4.5",
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
"main": "src/main.js",
"bin": "src/main.js",
@ -44,20 +44,20 @@
"tileserver-gl-styles": "2.0.0"
},
"devDependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"chai": "4.3.7",
"eslint": "^8.32.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-jsdoc": "^39.6.8",
"eslint-plugin-jsdoc": "^40.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-security": "^1.7.0",
"eslint-plugin-security": "^1.7.1",
"husky": "^8.0.3",
"lint-staged": "^13.1.0",
"lint-staged": "^13.1.2",
"mocha": "^10.2.0",
"prettier": "^2.8.3",
"prettier": "^2.8.4",
"should": "^13.2.3",
"supertest": "^6.3.3",
"yaml-lint": "^1.7.0"

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,19 +6,35 @@ import fs from 'node:fs';
import clone from 'clone';
import glyphCompose from '@mapbox/glyph-pbf-composite';
export const getPublicUrl = (publicUrl, req) =>
publicUrl || `${req.protocol}://${req.headers.host}/`;
/**
* Generate new URL object
* @params {object} req - Express request
* @returns {URL} object
**/
const getUrlObject = (req) => {
const urlObject = new URL(`${req.protocol}://${req.headers.host}/`);
// support overriding hostname by sending X-Forwarded-Host http header
urlObject.hostname = req.hostname;
return urlObject;
};
export const getPublicUrl = (publicUrl, req) => {
if (publicUrl) {
return publicUrl;
}
return getUrlObject(req).toString();
};
export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
const urlObject = getUrlObject(req);
if (domains) {
if (domains.constructor === String && domains.length > 0) {
domains = domains.split(',');
}
const host = req.headers.host;
const hostParts = host.split('.');
const hostParts = urlObject.host.split('.');
const relativeSubdomainsUsable =
hostParts.length > 1 &&
!/^([0-9]{1,3}\.){3}[0-9]{1,3}(\:[0-9]+)?$/.test(host);
!/^([0-9]{1,3}\.){3}[0-9]{1,3}(\:[0-9]+)?$/.test(urlObject.host);
const newDomains = [];
for (const domain of domains) {
if (domain.indexOf('*') !== -1) {
@ -34,7 +50,7 @@ export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
domains = newDomains;
}
if (!domains || domains.length == 0) {
domains = [req.headers.host];
domains = [urlObject.host];
}
const queryParams = [];