Hosting Gitea behind Traefik reverse proxy. Need help

I’m trying to host Gitea on docker using docker-compose. I’m able to access Gitea locally, but when trying to access from domain I’m having following error.

kex_exchange_identification: client sent invalid protocol identifier “GET / HTTP/1.1”
send_error: write: Broken pipe
kex_exchange_identification: client sent invalid protocol identifier “GET /favicon.ico HTTP/1.1”
send_error: write: Broken pipe

Docker-compose

version: "2"

services:
  gitea:
    image: gitea/gitea:latest
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - PROTOCOL=https
      - DOMAIN=git.DOMAIN.com
      - ENABLE_LETSENCRYPT=true
      - LETSENCRYPT_ACCEPTTOS=true
      - LETSENCRYPT_DIRECTORY=https
      - LETSENCRYPT_EMAIL=mail@mail.com
    restart: always
    labels:
        - traefik.enable=true
        - traefik.docker.network=web
        - traefik.http.routers.gitea.rule=Host(`git.DOMAIN.com`)
        - traefik.http.routers.gitea.tls=true
        - traefik.http.routers.gitea.tls.certresolver=le
        - traefik.http.routers.gitea.entrypoints=websecure
        - traefik.http.middlewares.gitea-redirect-web-secure.redirectscheme.scheme=https
        - traefik.http.routers.gitea-web.middlewares=gitea-redirect-web-secure
        - traefik.http.routers.gitea-web.rule=Host(`git.DOMAIN.com`)
        - traefik.http.routers.gitea-web.entrypoints=web
    networks:
      - web
    volumes:
      - /data/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "2222:22"
    
networks:
    web:
        external: false

I’m using Traefik 2.0.7. I already had Traefik+Letsencrypt working from docker-compose at https://github.com/JoshBlades/ncbuilder

Hello,
I also run gitea behind traefik (v1.7 in my case, I still have upgraded to v2), and I think you do not need to translate the web port (3000).
Could you test that ?

...
    expose:
       - "3000"
    ports:
       - "2222:22"
...

If that does not work, could you test the modification up here + this label:

  labels :
     - traefik.http.services.my-service.loadbalancer.server.port=3000

Thanks Mageti, For some reason expose didn’t work. But I added services to labels. It is working now :partying_face::smile:.

I have added batch environment variable while trying to fix it. Now I have to do some trial and error method to remove some of them.