Osrm-backend: Invalid URL when using proxy

Created on 9 Jun 2017  路  3Comments  路  Source: Project-OSRM/osrm-backend

Sorry if this is the same as another issue, but when i use Nginx as a proxy to allow for SSL and remove the need to quote a port in the URL, I get:

message "URL string malformed close to position 5: "ar/nea""
code "InvalidUrl"

This seems to occur because the url has an additional level of depth (in this case my_proxy_name):

https://www.my_url.com/my_proxy_name/nearest/v1/car/13.388860,52.517037?number=3&bearings=0,20

It works fine however if in the settings of the Nginx proxy I don't declare a name, thus have a direct proxy to the root of the domain, it works fine:

https://www.my_url.com/nearest/v1/car/13.388860,52.517037?number=3&bearings=0,20

Is there an issue with parsing an additional level of the URL?

Most helpful comment

Yes I'm sorry I should have mentioned, I am indeed running osrm-routed. Thank you for the information, that has indeed solved my issue, I appreciate you taking the time to explain this.

All 3 comments

@JamesLawrenceGSI Assuming you're running osrm-routed behind the proxy, then yes, if you've added extra path elements to your external URL namespace, you'll need to re-write the requests that are passed to osrm-routed and remove the my_proxy_name/ part of the path.

Something like this will be close:

location ~ /my_proxy_name/(?<OSRMREQUEST>.*) {
    proxy_pass http://localhost:5000/$OSRMREQUEST;
    proxy_set_header Host $host;
}

Yes I'm sorry I should have mentioned, I am indeed running osrm-routed. Thank you for the information, that has indeed solved my issue, I appreciate you taking the time to explain this.

Hi, I had to change "localhost" (you have a typo in the snippet above btw) to "127.0.0.1" and then it worked.

location ~ /my_proxy_name/(?<OSRMREQUEST>.*) {
        proxy_pass http://127.0.0.1:5100/$OSRMREQUEST;
        proxy_set_header Host $host;
    }

Btw the location of this config file is at : /etc/nginx/sites-available/

And then restart nginx:

sudo systemctl restart nginx
Was this page helpful?
0 / 5 - 0 ratings