302 redirect loop to /install on first access #1198

Closed
opened 2025-11-02 03:52:07 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @tYYGH on GitHub (Oct 31, 2017).

  • Gitea version (or commit ref): 1.2.2
  • Git version: 2.15.0
  • Operating system: up-to-date Archlinux
  • Database (use [x]):
    • PostgreSQL
  • Can you reproduce the bug at https://try.gitea.io:
    • Not relevant
  • Log gist:
nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Started GET /git/ for 192.168.1.99
nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Completed /git/ 302 Found in 788.45µs
nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] Session ID: 5cad889bf6b4e7c9
nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] CSRF Token: n2ty_h3E5Twk5ryVp16hCAabY7I6MTUwOTQ5MDc3NDkyMDU2NjUyNQ==
nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Started GET /git/install for 192.168.1.99
nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Completed /git/install 302 Found in 645.937µs
nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] Session ID: 5cad889bf6b4e7c9
nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] CSRF Token: n2ty_h3E5Twk5ryVp16hCAabY7I6MTUwOTQ5MDc3NDkyMDU2NjUyNQ==
nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Started GET /git/install for 192.168.1.99
nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Completed /git/install 302 Found in 636.412µs
nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] Session ID: 5cad889bf6b4e7c9
nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] CSRF Token: n2ty_h3E5Twk5ryVp16hCAabY7I6MTUwOTQ5MDc3NDkyMDU2NjUyNQ==

and so on…

Description

I installed Gitea under the URL prefix “/git”. ROOT_URL is configured as https://yalis.fr/git.
The Nginx configuration for Gitea is:

location /git {
  proxy_pass http://unix:/run/shared_sockets/gitea:;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
}

/git is correctly redirected to /git/install (first access), and then it keeps redirecting to /git/install in an infinite loop.

Originally created by @tYYGH on GitHub (Oct 31, 2017). - Gitea version (or commit ref): 1.2.2 - Git version: 2.15.0 - Operating system: up-to-date Archlinux - Database (use `[x]`): - [x] PostgreSQL - Can you reproduce the bug at https://try.gitea.io: - [x] Not relevant - Log gist: ``` nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Started GET /git/ for 192.168.1.99 nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Completed /git/ 302 Found in 788.45µs nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] Session ID: 5cad889bf6b4e7c9 nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] CSRF Token: n2ty_h3E5Twk5ryVp16hCAabY7I6MTUwOTQ5MDc3NDkyMDU2NjUyNQ== nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Started GET /git/install for 192.168.1.99 nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Completed /git/install 302 Found in 645.937µs nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] Session ID: 5cad889bf6b4e7c9 nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] CSRF Token: n2ty_h3E5Twk5ryVp16hCAabY7I6MTUwOTQ5MDc3NDkyMDU2NjUyNQ== nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Started GET /git/install for 192.168.1.99 nov. 01 00:01:56 sphinx3 gitea[8225]: [Macaron] 2017-11-01 00:01:56: Completed /git/install 302 Found in 636.412µs nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] Session ID: 5cad889bf6b4e7c9 nov. 01 00:01:56 sphinx3 gitea[8225]: 2017/11/01 00:01:56 [D] CSRF Token: n2ty_h3E5Twk5ryVp16hCAabY7I6MTUwOTQ5MDc3NDkyMDU2NjUyNQ== ``` and so on… ## Description I installed Gitea under the URL prefix “/git”. `ROOT_URL` is configured as `https://yalis.fr/git`. The Nginx configuration for Gitea is: ``` location /git { proxy_pass http://unix:/run/shared_sockets/gitea:; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } ``` `/git` is correctly redirected to `/git/install` (first access), and then it keeps redirecting to `/git/install` in an infinite loop.
GiteaMirror added the type/bug label 2025-11-02 03:52:07 -06:00
Author
Owner

@lunny commented on GitHub (Nov 1, 2017):

It should be a bug related sub url setup.

@lunny commented on GitHub (Nov 1, 2017): It should be a bug related sub url setup.
Author
Owner

@tYYGH commented on GitHub (Nov 2, 2017):

Solved :-)
I expected the Gitea server to work with the same paths as those stemming from ROOT_URL, hence the simple “:” at the end of the Nginx proxy-pass line. Actually the Gitea server works on /.
I had not seen it at first because replacing : with :/ in the Nginx proxy-pass line should have been enough but did not work. The working solution is to also append a / to the Nginx location line! My working configuration is now:

location = /git {
  rewrite ^ /git/ last;
}
location /git/ {
  proxy_pass http://unix:/run/shared_sockets/gitea:/;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
}
@tYYGH commented on GitHub (Nov 2, 2017): Solved :-) I expected the Gitea server to work with the same paths as those stemming from ROOT_URL, hence the simple “`:`” at the end of the Nginx `proxy-pass` line. Actually the Gitea server works on `/`. I had not seen it at first because replacing `:` with `:/` in the Nginx `proxy-pass` line should have been enough but did not work. The working solution is to _also_ append a `/` to the Nginx `location` line! My working configuration is now: ``` location = /git { rewrite ^ /git/ last; } location /git/ { proxy_pass http://unix:/run/shared_sockets/gitea:/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#1198