I’m setting up Nginx to work with a Martin server from MapLibre (https://maplibre.org/martin/introduction.html).
I want to configure Nginx to handle two specific paths:
-Requests to /martin/json/
should be forwarded to the Martin server for JSON responses.
-Requests to /martin/protobuf/
should be forwarded to the Martin server for protobuf responses.
The Nginx configuration : https://pastebin.com/dKyqc8wN
I added add_header Content-Type application/json;
and proxy_set_header Accept application/json;
to the /martin/json/ section to ensure that only JSON requests are accepted.
Also in the /martin/protobuf/ section I used add_header Content-Type application/x-protobuf;
and proxy_set_header Accept application/x-protobuf;
for Protobuf requests.
The routing and blocking of requests are not working as intended.
Here’s what I observe:
- Requests to http://server-ip/martin/json/world_cities are correctly forwarded to the Martin server as http://127.0.0.1:3000/world_cities, and this works as expected.
- Requests to http://server-ip/martin/json/world_cities/1/1/1 should be blocked, but they are incorrectly forwarded to the Martin server as http://127.0.0.1:3000/world_cities/1/1/1, which is not the desired.
- Requests to http://server-ip/martin/protobuf/world_cities/1/1/1 are forwarded to the Martin server as http://127.0.0.1:3000/world_cities/1/1/1, and this works as intended.
- Requests to http://server-ip/martin/protobuf/world_cities should be blocked, but they are incorrectly forwarded to the Martin server as http://127.0.0.1:3000/world_cities, which is not the desired.
I suspect that Martin is not considering the Accept header of the requester.
Is there a mistake in my Nginx configuration?
I appreciate any help or guidance on this issue. Thank you!