504 Errors with Reverse Proxy in Docker

Are there any known issues running Gitea in a docker container behind a reverse proxy? For years we have experienced sporadic 504 errors that occur more often than not. We can’t seem to find any rhyme or reason to it. Sometimes it just works and most times it doesn’t.

  • Always a 504
  • Occurs whether cloning, pulling or pushing
  • Across multiple clients: VS (MinGit), VSCode, TortoiseGit
  • Across multiple reverse proxies: recently migrated from Zoraxy to Nginx. Same behavior.
  • Not a high-volume instance
  • All traffic is http (not s) on internal network - no pushing/pulling over internet.
  • Version 1.25.3

504 is the proxy giving up waiting on gitea. since it followed you from zoraxy to nginx its the timeouts + git smart-http buffering, not the proxy brand.

nginx:

location / {
proxy_pass http://gitea:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
proxy_read_timeout 3600;
proxy_send_timeout 3600;
proxy_buffering off;
proxy_request_buffering off;
}

ROOT_URL in gitea has to match what the clients actually use, even on plain http.

git over ssh skips this whole mess if you can open 2222. docker logs on the gitea container while you push, if gitea itself is stuck the timeout is just the symptom.