docs: Too Many Redirects when logging in from Mobile Apps when Server is using subpath hosting
Summary
Too Many Redirects when logging in from Mobile Apps when Server is using subpath hosting. Tested in 9.7.1 and with 9.7.2
Steps to reproduce
- Configure Mattermost Server to use subpath hosting (like https://mattermostserver/chat)
- Ensure Android App or iOS App is logged out
- Try to Connect to the server (I used gitlab authentication, but never got threre)
Expected behavior
Connection Form should disappear and Login form should be displayed
Observed behavior (that appears unintentional)
An error is being displayed “Too many redirects (21)”
According the nginx logs a HEAD request proxied to http://mattermost/chat, which gets redirected to http://mattermost/chat/chat then to http://mattermost/chat/chat then to http://mattermost/chat/chat/
The same can be reproduced using curl:
curl -L -I http://mattermost-server:8065/chat/
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /chat/chat
Vary: Origin
X-Ratelimit-Limit: 101
X-Ratelimit-Remaining: 100
X-Ratelimit-Reset: 1
Date: Fri, 26 Apr 2024 10:31:03 GMT
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /chat/chat/chat
Vary: Origin
X-Ratelimit-Limit: 101
X-Ratelimit-Remaining: 99
X-Ratelimit-Reset: 1
Date: Fri, 26 Apr 2024 10:31:03 GMT
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /chat/chat/chat/chat
Vary: Origin
X-Ratelimit-Limit: 101
X-Ratelimit-Remaining: 98
X-Ratelimit-Reset: 1
Date: Fri, 26 Apr 2024 10:31:03 GMT
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /chat/chat/chat/chat/chat
Vary: Origin
X-Ratelimit-Limit: 101
X-Ratelimit-Remaining: 97
X-Ratelimit-Reset: 1
Date: Fri, 26 Apr 2024 10:31:03 GMT
...
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat/chat
Vary: Origin
X-Ratelimit-Limit: 101
X-Ratelimit-Remaining: 50
X-Ratelimit-Reset: 6
Date: Fri, 26 Apr 2024 10:31:03 GMT
curl: (47) Maximum (50) redirects followed
The problem also occurs when starting with http://mattermost/chat/
The problem does not occur when using a GET Request like curl http://mattermost/chat. In this case the main html is correctly being retured.
Possible fixes
Ensure the HEAD request does no endless redirects to the subpath even when already on the subpath.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 22 (7 by maintainers)
That seems reasonable. As long as an admin has set the SiteURL properly. I’ll reopen the JIRA ticket for a closer investigation. Please feel free to follow that for more updates.
Until then, I think anyone using sub-paths should be unblocked with the above workaround.
The fix would be to behave correctly, just like the same GET request would.
Or the other way: A HEAD request to the mattermost server beginning with the subpath (/chat/) should not perform a redirect append the subpath again and again and again ad infinitum, but respond just like a GET Request to the same path with the information about the requested resource as it does when not using a subpath.
This is definitely a bug in the mattermost server and and should not be fixed trough reverse proxy configurations.
I don’t think this has been fixed, exactly: the underlying problem still persists, all that #7188 does is document the workaround. Could this please be re-opened?
Ok, so the issue is that a
HEADrequest on the sub-path used to return a 302 with the sub-path added again which led to an infinite loop. I think then returning a200 OKwould be a better response to fix this.@cwarnermm - Something to document in our nginx docs. If the customer is setting MM in a sub-path, then a block like this:
should be added.
We’re experiencing the same thing, with Nginx as well. Can confirm that returning 405 to HEAD requests to our subpath “fixed” the issue.
Opened https://mattermost.atlassian.net/browse/MM-58042