https://github.com/arrayiterator/osrm-server
Route Map Binding API
https://github.com/arrayiterator/osrm-server
logistics map nginx nodejs osm osrm polyline
Last synced: about 1 month ago
JSON representation
Route Map Binding API
- Host: GitHub
- URL: https://github.com/arrayiterator/osrm-server
- Owner: ArrayIterator
- License: mit
- Created: 2020-02-10T09:16:03.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-07T20:05:15.000Z (6 months ago)
- Last Synced: 2025-02-15T06:30:37.478Z (3 months ago)
- Topics: logistics, map, nginx, nodejs, osm, osrm, polyline
- Language: JavaScript
- Homepage:
- Size: 40.9 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## OSRM
OSRM API NODEJSOSRM implementation for API.
Opened cause no benefit from the previous company to the coder!### PRE-REQUIRES
- UBUNTU Server
- NodeJS ^v10
- Global `node-pre-gyp`, `node-gyp`, `nodemon`
```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/testsudo apt-get update -y
sudo apt install build-essential git cmake pkg-config \
libbz2-dev libxml2-dev libzip-dev libboost-all-dev \
lua5.2 liblua5.2-dev libtbb-dev libstdc++-5-dev```
see [https://github.com/Project-OSRM/osrm-backend](https://github.com/Project-OSRM/osrm-backend)
Follow OSRM data storage [README.md](storage/data/osrm/README.md)
### DEPENDS NODE
- osrm@^5.22.0
- expresss@^4.1
- maxmind@^4.1.0
- yaml@^1.7.2
- express-group-routes@^1.1.0### REF URI
- GEOIP : [https://db-ip.com/db/lite.php](https://db-ip.com/db/lite.php)
- OSRM : [https://github.com/Project-OSRM/](https://github.com/Project-OSRM/)
- OSM : [https://openstreetmap.org](https://openstreetmap.org)
- GEO JSON - see [world.geo.json](world.geo.json)
- [https://github.com/johan/world.geo.json](https://github.com/johan/world.geo.json)
- [https://github.com/datasets/geo-countries](https://github.com/datasets/geo-countries)
- [https://gist.github.com/ArrayIterator/015b3bbb40828513d402e397105110e3](https://gist.github.com/ArrayIterator/015b3bbb40828513d402e397105110e3)### PORT LISTEN
- PORT : `5050` to `5059`
### RUN DAEMON
Running [`osrm-server.sh`](osrm-server.sh) as daemon background service :
```bash
setsid ./osrm-server.sh >/dev/null 2>&1 < /dev/null &
```### REQUESTING
add header `X-Auth-Token` with with declared token to get access
### NGINX CONFIG
```conf
# MAKE SURE INSTALL MOD UPSTREAM & FAIR
# FILE $domain.vhost.conf
# NGINX NODE UPSTREAM ADD MAX FAILS 3 & FAILED TIMEDOUT 30 SECONDS
upstream node_proxy_osrm {
least_conn;
server 127.0.0.1:5050 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5051 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5052 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5053 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5054 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5055 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5056 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5057 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5058 max_fails=3 fail_timeout=30s;
server 127.0.0.1:5059 max_fails=3 fail_timeout=30s;
fair;
}server {
listen 80;
# listen 443 ssl http2;# ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem;# ROOT PATH JUST TO TRY FILES
root /home/$user/host/$domain/public;# SERVER NAME / DOMAIN
server_name $domain www.$domain;# SET DEFAULT MIME TYPE
default_type text/html;
# ADD PROXY HEADER
proxy_set_header X-Forwarded-For $remote_addr;
# ADD REAL HOST
proxy_set_header Host $http_host;# ------------------------------------------------------------
# ERROR HANDLER
# ------------------------------------------------------------# INDEX (NOT USED) NO INDEX TO MAKE SURE HANDLE BY NGINX
# index '#';# ERROR HANDLER
location = '/#401' {
default_type application/json;
add_header Content-Type application/json;
return 401 '{
"message": "401 Unauthorized"
}';
}
location = '/#404' {
default_type application/json;
add_header Content-Type application/json;
return 404 '{
"message": "404 Not Found"
}';
}
location = '/#403' {
default_type application/json;
add_header Content-Type application/json;
return 403 '{
"message": "403 Forbidden"
}';
}
location = '/#500' {
default_type application/json;
add_header Content-Type application/json;
return 500 '{
"message": "500 Internal Server Error"
}';
}
location = '/#502' {
default_type application/json;
add_header Content-Type application/json;
return 502 '{
"message": "502 Bad Gateway"
}';
}
location = '/#504' {
default_type application/json;
add_header Content-Type application/json;
return 504 '{
"message": "504 Gateway Timeout"
}';
}# HANDLE ERROR
error_page 401 '/#401';
error_page 404 '/#404';
error_page 403 '/#403';
error_page 500 '/#500';
error_page 502 '/#502';
error_page 504 '/#504';# ------------------------------------------------------------
# LOCATIONS
# ------------------------------------------------------------location @proxy {
proxy_pass http://node_proxy_osrm;
}# HANDLE LOCATION
# use try_files $uri @proxy; -> to prevent accessing directory as allowed url index
location / {
try_files $uri $uri/ @proxy;
}
}```
### AUTHOR
Github : [@ArrayIterator](https://github.com/ArrayIterator)
### LICENSE
[MIT LICENSE](LICENSE)