Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Off-topic
  3. I need help understanding trailing slash behaviour in Nginx

I need help understanding trailing slash behaviour in Nginx

Scheduled Pinned Locked Moved Off-topic
nginxreverseproxyminecraft
2 Posts 2 Posters 340 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amoslipara
    wrote on last edited by
    #1

    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:39000

    Configuration:

    location /squaremap {
       proxy_pass http://127.0.0.1:39000;
    }
    

    Result: Accessing https://example.com/squaremap returns a 404 error.

    location /squaremap {
        proxy_pass http://127.0.0.1:39000/;
    }
    

    Result: https://example.com/squaremap shows a blank page, but https://example.com/squaremap/ works fine.

    location /squaremap/ {
        proxy_pass http://127.0.0.1:39000/;
    }
    

    Result:

    https://example.com/squaremap redirects to https://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:

    1. If there's no URI in the proxy_pass directive, the request URI is passed to the upstream unchanged.
    2. 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:

    1. Is my interpretation of how nginx processes these requests correct?
    2. Why do I get different results in cases 2a and 3, even though they seem to send the same request to the upstream?
    3. Why doesn't it work without the trailing slash, but works with it?
    4. Is there a configuration that would allow both /squaremap and /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.

    1 Reply Last reply
    0
    • J joseph moved this topic from Support on
    • J Offline
      J Offline
      joseph
      Staff
      wrote on last edited by
      #2

      @amoslipara this is a Cloudron forum . Not a Minecraft forum or a Linux help forum. Did you intend to post it here?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Bookmarks
      • Search