-
I'm setting up nginx as a reverse proxy for squaremap (a world map viewer for Minecraft servers) and encountering unexpected behavior with trailing slashes. I've followed the squaremap documentation for serving with nginx acting as a reverse proxy (https://github.com/jpenilla/squaremap/wiki/Internal-vs-External-Web-Server), but I'm confused by the results. Here's what I've tried:
squaremap is running at
127.0.0.1:39000Configuration:
location /squaremap { proxy_pass http://127.0.0.1:39000; }Result: Accessing
https://example.com/squaremapreturns a 404 error.location /squaremap { proxy_pass http://127.0.0.1:39000/; }Result:
https://example.com/squaremapshows a blank page, buthttps://example.com/squaremap/works fine.location /squaremap/ { proxy_pass http://127.0.0.1:39000/; }Result:
https://example.com/squaremapredirects tohttps://example.com/squaremap/and then displays the web interface.
https://example.com/squaremap/works as expected.In my attempt to figure out what was happening, I read part of the nginx documentation on
proxy_pass. However, I'm not sure if my interpretation is correct. My understanding is:- If there's no URI in the proxy_pass directive, the request URI is passed to the upstream unchanged.
- If there is a URI in the proxy_pass directive, the part of the request matching the location directive is substituted by the value of the URI in the proxy_pass directive.
Based on this, I created a table of what I think is happening in each of the above cases:
Case Original Request Request to Upstream Result 1 https://example.com/squaremap/squaremap Error 404 2.a https://example.com/squaremap/ White page 2.b https://example.com/squaremap/// Works 3 https://example.com/squaremap// Works My questions are:
- Is my interpretation of how nginx processes these requests correct?
- Why do I get different results in cases
2aand3, even though they seem to send the same request to the upstream? - Why doesn't it work without the trailing slash, but works with it?
- Is there a configuration that would allow both
/squaremapand/squaremap/to work correctly without a redirect?
I'd appreciate any insights into understanding this behavior and how to properly configure nginx for this use case.
-
J joseph moved this topic from Support on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login