ByteByteGo 그림을 며칠 올렸으니 오늘은 주제를 바꿔 보겠습니다.

GitLab이나 Gitea를 Coolify에 배포해서 쓰다 보면 다음과 같은 오류가 날 때가 있습니다.

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v <내-remote> <로컬-브랜치>:<원격-브랜치>
POST git-receive-pack (chunked)
error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Pushing to <내-git-url>
Everything up-to-date
Completed with errors, see above.

검색하다 보면 다음과 같이 Git의 버퍼 크기를 조정하라는 해결책을 찾을 수도 있습니다.

1
git config --global http.postBuffer <아주-큰-숫자>

git config http.postBuffer로 해결되지 않는 이유

Git의 http.postBuffer란?

  • Git이 HTTP POST로 데이터를 보낼 때 사용하는 버퍼 크기입니다.
  • Git은 기본적으로 데이터를 작은 청크(보통 1MB)로 나눠 보냅니다.
  • postBuffer를 늘리면 더 큰 청크로 보내므로 요청 횟수가 줄어듭니다.

이번 경우에는 왜 효과가 없을까요?

문제는 Git이 데이터를 보내는 방식이 아니라 Coolify 프록시의 HTTP 타임아웃에 있습니다.

  1. Git은 데이터를 Traefik 프록시로 전송합니다.
  2. Traefik 프록시는 Git 서버(GitLab 또는 Gitea)의 응답을 기다립니다.
  3. Git 서버는 압축, 인덱싱, 검증 등 데이터를 처리하는 데 시간이 걸립니다.
  4. Git 서버가 응답하기 전에 Traefik에서 타임아웃이 발생하면 HTTP 504가 반환됩니다.

Git이 큰 청크를 보내든 작은 청크를 보내든 Git 서버에서 데이터를 처리하는 데 걸리는 시간은 달라지지 않습니다. 따라서 postBuffer를 늘려도 프록시 계층의 타임아웃은 해결되지 않습니다.

구성과 오류 원인

git push 요청 흐름

Git Client → Traefik Proxy → Git Server (GitLab/Gitea)
     ↑                ↑              ↑
  postBuffer    readTimeout     Processing time

단계별 동작

  1. Git 클라이언트가 HTTP POST로 데이터를 보냅니다. 저장소가 크면 몇 초 걸릴 수 있습니다.
  2. Traefik 프록시가 요청을 받아 Git 서버로 전달합니다.
  3. Git 서버가 처리를 시작합니다.
    • 객체 압축 해제
    • 무결성 확인
    • 참조 업데이트
    • Git 훅이 있으면 실행
  4. Traefik이 readTimeout(기본값 약 30초) 동안 응답을 기다립니다.
  5. Git 서버의 처리가 이보다 오래 걸리면 Traefik이 HTTP 504를 반환합니다.

Coolify에서 이 오류가 발생하는 이유

  • Coolify는 Traefik을 리버스 프록시로 사용합니다.
  • Traefik의 기본 readTimeout은 꽤 짧습니다.
  • 대용량 파일이나 저장소를 다루는 Git 작업은 처리에 30초 넘게 걸리는 경우가 흔합니다.
  • Git뿐 아니라 처리 시간이 긴 다른 HTTP 서비스에서도 이 오류가 발생할 수 있습니다.

해결 방법

Server에서 해당 서버(일반적으로 localhost)를 선택한 다음 Proxy > Configuration으로 이동합니다.

1

services.traefik.command에 다음 줄을 추가합니다.

1
2
- '--entrypoints.http.transport.respondingTimeouts.readTimeout=600s'
- '--entrypoints.https.transport.respondingTimeouts.readTimeout=600s'

설정값

  • readTimeout: Traefik이 백엔드의 응답을 읽을 때까지 기다리는 최대 시간입니다.
  • 600s(10분): 규모가 큰 Git 푸시 작업에 적합한 시간입니다.
  • 저장소의 크기와 네트워크 속도에 따라 조정할 수 있습니다.

아래는 전체 구성 예시입니다. Coolify의 후속 버전에서는 내용이 달라질 수 있으니 항목을 추가하는 방법을 참고하는 용도로만 보세요.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: coolify-proxy
networks:
  coolify:
    external: true
services:
  traefik:
    container_name: coolify-proxy
    image: 'traefik:v3.1'
    restart: unless-stopped
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    networks:
      - coolify
    ports:
      - '80:80'
      - '443:443'
      - '443:443/udp'
      - '8080:8080'
    healthcheck:
      test: 'wget -qO- http://localhost:80/ping || exit 1'
      interval: 4s
      timeout: 2s
      retries: 5
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:ro'
      - '/data/coolify/proxy/:/traefik'
    command:
      - '--ping=true'
      - '--ping.entrypoint=http'
      - '--api.dashboard=true'
      - '--entrypoints.http.address=:80'
      - '--entrypoints.https.address=:443'
      - '--entrypoints.http.http.encodequerysemicolons=true'
      - '--entryPoints.http.http2.maxConcurrentStreams=250'
      - '--entrypoints.https.http.encodequerysemicolons=true'
      - '--entryPoints.https.http2.maxConcurrentStreams=250'
      - '--entrypoints.https.http3'
      - '--providers.file.directory=/traefik/dynamic/'
      - '--providers.file.watch=true'
      - '--certificatesresolvers.letsencrypt.acme.httpchallenge=true'
      - '--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=http'
      - '--certificatesresolvers.letsencrypt.acme.storage=/traefik/acme.json'
      - '--api.insecure=false'
      - '--providers.docker=true'
      - '--providers.docker.exposedbydefault=false'
      - '--entrypoints.http.transport.respondingTimeouts.readTimeout=600s'
      - '--entrypoints.https.transport.respondingTimeouts.readTimeout=600s'
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik.entrypoints=http
      - traefik.http.routers.traefik.service=api@internal
      - traefik.http.services.traefik.loadbalancer.server.port=8080
      - coolify.managed=true
      - coolify.proxy=true

변경 사항 적용

  1. Save를 눌러 Traefik 설정을 저장합니다.
  2. Restart Proxy를 눌러 프록시를 재시작하고 새 타임아웃을 적용합니다.
  3. 확인. 프록시가 다시 작동할 때까지 기다립니다. 보통 30~60초 걸립니다.

주의할 점

  • 타임아웃을 너무 길게 잡지 마세요. 실제 오류가 생기면 연결이 오랫동안 멈춰 있을 수 있습니다.
  • 작은 저장소에서 먼저 테스트하세요. 설정이 제대로 작동하는지 확인합니다.
  • 로그를 살펴보세요. 문제가 있으면 Coolify와 Traefik 로그를 확인합니다.

잘 해결해서 얼른 코드를 푸시할 수 있길 바랍니다!