osrm-backend: OSRM server HTTP request failed:undefined

This is my first question. My name is shin2.

I’m trying to set up an OSMR server on my home web server using the following site as a reference, but I’m having trouble with an error at the final stage. If you have any good advice, please let me know. PS I’m not good at English

【System Environment】 OS:ubuntu22.04 Webserver:nginx/1.18.0 (Ubuntu) domain&SSL:Acquisition Site Web browser:Brave

【Reference sites】 https://www.linuxbabe.com/ubuntu/install-osrm-ubuntu-22-04-open-source-routing-machine

【Server】

$ sudo nano /etc/nginx/nginx.conf 
#After that create osrm.conf
include /etc/nginx/conf.d/*.conf;
#nginx Virtual Server
include /etc/nginx/sites-enabled/*;
$ sudo nano /etc/nginx/conf.d/osrm.conf
server {
    listen 80;
    #listen [::]:80;
    server_name signpost.mydns.jp;
    access_log /var/log/nginx/osrm.access;
    error_log /var/log/nginx/osrm.error;
   
    location /mapNavi {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Protocol $scheme;
        proxy_set_header X-Forwarded-Host $http_host;
    }
}
$ sudo nano /etc/nginx/sites-available/globalServer
#signpost global(443)
server {
    server_name signpost.mydns.jp www.signpost.mydns.jp;
    access_log /mnt/WebSite/logs/signpost_access.log;
    error_log /mnt/WebSite/logs/signpost_error.log;
    root /mnt/WebSite/signpost;
    index  index.html index.php;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/signpost.mydns.jp-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/signpost.mydns.jp-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    add_header Strict-Transport-Security "max-age=31536000" always; # managed by Certbot
    ssl_trusted_certificate /etc/letsencrypt/live/signpost.mydns.jp-0001/chain.pem; # managed by Certbot
}

server {
    if ($host = signpost.mydns.jp) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    return 404; # managed by Certbot
}

【html excerpt】

    routeControl = L.Routing.control({ 
//------------------------------------------------------------------------------------------
        //https://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/
        router: L.Routing.osrmv1({
            //OSRM Demo server
            //serviceUrl: 'https://router.project-osrm.org/route/v1' >>>OK

            //myOSRM server 
            serviceUrl: 'https://signpost.mydns.jp/route/v1',  >>>ERROR
        }),
//------------------------------------------------------------------------------------------
}).addTo(map);

【Web Site Error】 https://signpost.mydns.jp/mapNavi01/naviplan01.html Routing error Calculating the route caused an error Technical description folloes HTTP request failed:undefined

Is this error related? window.XMLHttpRequest === ‘undefined’ if (typeof window.XMLHttpRequest === ‘undefined’) { return callback(Error(‘Browser not supported’)); } I don’t have the knowledge to solve this myself, so can someone tell me how to fix it?

About this issue

Most upvoted comments

I am sorry but I did not see the ssl stuff in your globalServer. Please leave it as my note was a red herring %-)

As @curtisy1 mentioned you should have location /mapNavi/.

So you want https://signpost.mydns.jp/mapNavi/route/v1/driving …

When an incoming request comes with /mapNavi in the url nginx will proxy_pass http://127.0.0.1:5000/ ; On receiving the request nginx should strip mapNavi from the request and proxy to 127.0.0.1:5000/ Your earlier earlier note (the curl request) shows the osrm server is working o.k. So check the nginx proxy stuff Do you see anything in the error_log /mnt/WebSite/logs/signpost_error.log. You could enable warning errors (while you are testing - error_log /var/log/nginx/osrm.error warn;

I installed nginx and did a test. location /mapNavi/ { proxy_set_header Host $host; proxy_pass http://127.0.0.1:5000/ ; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Protocol $scheme; proxy_set_header X-Forwarded-Host $http_host;

it worked. Without the trailing slash on proxy_pass the location does not get stripped. Make sure slash after mapNavi and 5000. CIao