Empty URI in logs when using fcgi protocol #6674

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

Originally created by @WKBae on GitHub (Jan 12, 2021).

  • Gitea version (or commit ref): 1.13.1
  • Git version: 2.26.2
  • Operating system: Official Docker image; gitea/gitea:1.13.1
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:
[Macaron] 2021-01-12 10:00:58: Started GET  for xxx.xxx.xxx.xxx
[Macaron] [Static] Serving /serviceworker.js
[Macaron] 2021-01-12 10:00:58: Completed GET  304 Not Modified in 479.996µs
[Macaron] 2021-01-12 10:00:58: Completed GET  304 Not Modified in 479.996µs
[Macaron] 2021-01-12 10:00:58: Started GET  for xxx.xxx.xxx.xxx
[Macaron] 2021-01-12 10:00:58: Started GET  for xxx.xxx.xxx.xxx
[Macaron] 2021-01-12 10:00:58: Completed GET  200 OK in 3.775066ms
[Macaron] 2021-01-12 10:00:58: Completed GET  200 OK in 3.775066ms

Description

When using PROTOCOL = fcgi, request paths(http.Request.RequestURI) are not shown in the logs.

Go's net/http/cgi.RequestFromMap(), which net/http/fcgi uses, does not populate RequestURI(but does URL). As RequestURI is documented "Usually the URL field should be used instead", req.URL.RequestURI() may be a simple and recommended alternative.

9659808172/routers/routes/chi.go (L89)
9659808172/routers/routes/chi.go (L96)

Screenshots

None

Originally created by @WKBae on GitHub (Jan 12, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.13.1 - Git version: 2.26.2 - Operating system: Official Docker image; gitea/gitea:1.13.1 <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - Log gist: ``` [Macaron] 2021-01-12 10:00:58: Started GET for xxx.xxx.xxx.xxx [Macaron] [Static] Serving /serviceworker.js [Macaron] 2021-01-12 10:00:58: Completed GET 304 Not Modified in 479.996µs [Macaron] 2021-01-12 10:00:58: Completed GET 304 Not Modified in 479.996µs [Macaron] 2021-01-12 10:00:58: Started GET for xxx.xxx.xxx.xxx [Macaron] 2021-01-12 10:00:58: Started GET for xxx.xxx.xxx.xxx [Macaron] 2021-01-12 10:00:58: Completed GET 200 OK in 3.775066ms [Macaron] 2021-01-12 10:00:58: Completed GET 200 OK in 3.775066ms ``` <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## Description When using `PROTOCOL = fcgi`, request paths(`http.Request.RequestURI`) are not shown in the logs. Go's `net/http/cgi.RequestFromMap()`, which `net/http/fcgi` uses, does not populate `RequestURI`(but does `URL`). As `RequestURI` [is documented](https://golang.org/pkg/net/http/#Request) "Usually the URL field should be used instead", `req.URL.RequestURI()` may be a simple and recommended alternative. https://github.com/go-gitea/gitea/blob/9659808172b0d33a79eca44e37cabaf33fbf1b8b/routers/routes/chi.go#L89 https://github.com/go-gitea/gitea/blob/9659808172b0d33a79eca44e37cabaf33fbf1b8b/routers/routes/chi.go#L96 ## Screenshots None <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bug label 2025-11-02 07:03:27 -06:00
Author
Owner

@WKBae commented on GitHub (Jan 12, 2021):

Found #9473 this previous PR while investigating.

@WKBae commented on GitHub (Jan 12, 2021): Found #9473 this previous PR while investigating.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6674