[Doc] Gitea in sub-path config document is incompatible with path escaping #10519

Closed
opened 2025-11-02 09:10:07 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @wxiaoguang on GitHub (Mar 26, 2023).

Description

The ending slash shouldn't be used, because it causes nginx to unescape the path encodings, it breaks %2f in the path, breaks some Gitea git refs/paths and some Gitea package names/paths.

More details:

Thanks to @ghnp5

Originally created by @wxiaoguang on GitHub (Mar 26, 2023). ### Description * Correct: https://docs.gitea.io/en-us/reverse-proxies/#nginx * Buggy: https://docs.gitea.io/en-us/reverse-proxies/#nginx-with-a-sub-path The ending slash shouldn't be used, because it causes nginx to unescape the path encodings, it breaks `%2f` in the path, breaks some Gitea git refs/paths and some Gitea package names/paths. More details: * https://github.com/go-gitea/gitea/issues/20890#issuecomment-1483950304 Thanks to @ghnp5
GiteaMirror added the type/bug label 2025-11-02 09:10:07 -06:00
Author
Owner

@ghnp5 commented on GitHub (Mar 26, 2023):

Note that the "Buggy" section has a slash so that it will work for the sub-path.

If you remove the slash, all pages on Gitea will get a 404, because the "git/" sub-path is being passed to all URLs to Gitea.

To fix that, this hack is needed:

	location /git/ {
		# this hack prevents URL encoding, which can break the Packages area, for package names with slashes
		rewrite ^ $request_uri;
		rewrite ^/git(/.*) $1 break;
		return 400; # if the second rewrite won't match
		proxy_pass http://127.0.0.1:1234$uri;
@ghnp5 commented on GitHub (Mar 26, 2023): Note that the "Buggy" section has a slash so that it will work for the sub-path. If you remove the slash, all pages on Gitea will get a 404, because the "git/" sub-path is being passed to all URLs to Gitea. To fix that, this hack is needed: location /git/ { # this hack prevents URL encoding, which can break the Packages area, for package names with slashes rewrite ^ $request_uri; rewrite ^/git(/.*) $1 break; return 400; # if the second rewrite won't match proxy_pass http://127.0.0.1:1234$uri;
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10519