mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-19 14:42:41 -05:00
Sign in not possible behind tinyproxy with sub-path #13081
Closed
opened 2025-11-02 10:29:41 -06:00 by GiteaMirror
·
20 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v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.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#13081
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LauKr on GitHub (May 31, 2024).
Originally assigned to: @wxiaoguang on GitHub.
Description
Running Gitea behind a Reverse Proxy using a sub-path doesn't allow login.
This issue was first occurring with the update 1.21.10 -> 1.21.11 and
continues with 1.22.0.
After entering credentials and pressing the "Sign In" button, the
unauthenticated "root" site is shown again, like after a logout.
From the release notes
we noted the following change which seems suspicious:
Therefore, we checked our configurations and ensured, they used trailing slashes:
The logs from our reverse proxy show a behavior as requested by the
documentation:
We see the equivalent to
The corresponding Gitea logs are:
Access logs in Gitea:
Resolving
After reverting commit
b18c04ebde(and commentingout two sections undefined afterwards, see patch), we are able to use the normal
login again, when using our custom built binary. Thus, this also shows that our
error is connected to this change.
Gitea Version
1.21.11 and 1.22.0
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
2.39.2
Operating System
Debian Bookworm
How are you running Gitea?
The binary is pulled from the official server. Execution is happening through systemd on Debian 6.1.85-1 (2024-04-11) 86_64.
The Gitea server is listening locally via HTTP and is served by a tinyproxy reverse proxy. TLS is terminated by stunnel in front of tinyproxy.
Database
SQLite
@wxiaoguang commented on GitHub (May 31, 2024):
@jtran would you like to take a look?
@wxiaoguang commented on GitHub (May 31, 2024):
@LauKr could you help to elaborate some details?
Set-Cookie) and sent from client (Cookie)? Do they match?@LauKr commented on GitHub (May 31, 2024):
Sadly GitHub doesn't let me upload a file with .path extension. I changed it to .txt instead.
diff.txt
This diff shows the revert plus two comments that allowed us to login again.
@LauKr commented on GitHub (May 31, 2024):
@bohde commented on GitHub (May 31, 2024):
I worked with @jtran on this change for bug we were seeing in a deployment that is also behind a reverse proxy (nginx in our case) with a subpath of
/app_path/. Theset-cookieheaders as a result ofPOST /app_path/user/loginlook like the following in my Firefox network tab:@LauKr based on my reading of your config, it appears like your cookies should set
Path=/git-staging, but it appears that's not happening from theSet-Cookieheader your posted.@wxiaoguang commented on GitHub (Jun 1, 2024):
@LauKr it doesn't seem right in your reverse proxy config.
Did you see any
Set-Cookiefori_like_gitea? Which path is it on? It is directly related to Gitea login.And, did you set any
ReversePathor related config for your reverse proxy? I think they should be removed. UPDATE: maybe it should setReverseMagic No, see below.Since you are using tinyproxy, could you prepare a reproducible setup with detailed steps ? If you could provide a docker compose to reproduce, then I could try to debug it on my machine.
@wxiaoguang commented on GitHub (Jun 1, 2024):
And one more thing, It seems that tinyproxy does some trick (black magic?) on the "cookie path". https://github.com/search?q=repo%3Atinyproxy%2Ftinyproxy%20REVERSE_COOKIE&type=code
I do not feel it is quite right. If there is a chance, I would recommend to try to use some modern and standard reverse proxies.
ps: I guess setting
ReverseMagic Noshould resolve the problem, according to the code in tinyproxy:@wxiaoguang commented on GitHub (Jun 4, 2024):
Any update?
@LauKr commented on GitHub (Jun 4, 2024):
Sorry, I need some time for the reproducible build.
Changing
ReverseMagicto No sadly didn't resolve the issue. I'll try debugging where the cookie went as soon as I find the time.@LauKr commented on GitHub (Jun 9, 2024):
Hi,
sorry for the delay. I wrote a Dockerfile to reproduce the issue. Necessary files are attached:
setup_for_debugging.tar.gz
Building and running was tested using Podman, but should work with Docker as well:
The Dockerfile creates a container with Gitea and tinyproxy. The tinyproxy is accessible via port 8888.
Accessing Gitea via 127.0.0.1:8888/git-staging/ was successful, but login was not possible, as described in the issue.
@wxiaoguang commented on GitHub (Jun 10, 2024):
I guess the problem is caused by that the new cookie is correctly removed by the "deleting legacy code". So I think we could try to flip the order: first delete the legacy cookie, then set new cookie, then the new cookie won't be deleted.
-> Delete legacy cookie before setting new cookie #31306
@wxiaoguang commented on GitHub (Jun 11, 2024):
Wait for backport to 1.22
@LauKr commented on GitHub (Jun 11, 2024):
When trying use a custom build on commit
5342a61124, the problem was not fixed in the provided container setup.I'll have a look at the proxy again, just in case.
@lunny commented on GitHub (Jun 11, 2024):
Backport merged, wait for @LauKr 's confirmation and feedback.
@wxiaoguang commented on GitHub (Jun 11, 2024):
It's said that the "fix" doesn't work.
@wxiaoguang commented on GitHub (Jun 11, 2024):
I think it is a bug in tinyproxy. By using
tcpdump, I can see:Gitea tells tinyproxy:
Tinyproxy tells browsers
Tinyproxy loses most cookies for browsers.
@wxiaoguang commented on GitHub (Jun 11, 2024):
I would suggest to use a professional reverse proxy like nginx, which is also small enough and I guess it won't cost more resources than tinyproxy.
@LauKr commented on GitHub (Jun 11, 2024):
Thanks for the effort.
We will try to debug tinyproxy and create a separate issue there. Hopefully observing tinyproxy will show a clear reason why it cannot handle the changes mode by the mentioned commit.
Testing with NGINX looks promising, however we will have to consider the feature set etc. first, before switching.
@LauKr commented on GitHub (Jun 11, 2024):
For reference, if anyone happens to have the same issue:
https://github.com/tinyproxy/tinyproxy/issues/403 describes a relevant issue:
The corresponding PR is still open: https://github.com/tinyproxy/tinyproxy/pull/435
However, we were able to confirm the fix by building a custom version of
tinyproxy. As we use Debian, the Debian repository with corresponding release is used (https://salsa.debian.org/debian/tinyproxy/-/tags/debian%2F1.11.1-2) and the commits are applied on top.Using this custom version of
tinyproxya login into Gitea is possible.@wxiaoguang from my side this issue can be closed, as this is evidently no Gitea issue.
@wxiaoguang commented on GitHub (Jun 11, 2024):
Thank you very much for the details!