0

Setting Up a Gitea instance with a reverse proxy (NGINX) in docker-compose works fine for me. After logging in to the webapp creating repositories, changing settings, etc. works. Even cloning repositories via HTTPS works. However, cloning via SSH runs into

git clone git@localhost:martin/asd.git
Cloning into 'asd'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

How do I make process on identifying the problem? The docker-compose logs only show

production_nginx | 172.22.0.1 - - [19/Jun/2020:20:40:41 +0000] "SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3" 400 157 "-" "-"

which isn't helpful for me.

The code docker-compose file and my nginx config can be accesed via my GitHub repository

Docker-Compose.yml:

version: "2"

networks:
  reverseproxy:
  gitea:
    external: false

services:
  nginx:
    image: nginx:latest
    container_name: production_nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    ports:
      - "80:80"
      - "443:443"
      - "22:22"
    networks:
      - reverseproxy  
  server:
    image: gitea/gitea:latest
    environment:
      - APP_NAME=Gitea
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=postgres
      - DB_HOST=db:5432
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
      - DOMAIN=localhost
      - SSH_DOMAIN=localhost
      - HTTP_PORT=80
      - SSH_PORT=22
      - SSH_LISTEN_PORT=22
    restart: always
    networks:
      - gitea
      - reverseproxy
    volumes:
      - gitea_data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    expose:
      - "3000"
      - "22"
    depends_on:
        - db

  db:
    image: postgres:9.6
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=gitea
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - postgres:/var/lib/postgresql/data 

volumes:
  gitea_data: {}
  postgres: {}

nginx.conf

events {}
http {
  server {
    listen 80;
    server_name localhost;

    location / {
      proxy_pass http://gitea_server_1:3000;
    }
  }
  server {
    listen 22;
    server_name localhost;

    location / {
      proxy_pass http://gitea_server_1:22;
    }
  }
}

Martin Müsli
  • 1,031
  • 3
  • 14
  • 26
  • 1. You repo is gone, or private, 2. Update your question with the config. – abestrad Jun 20 '20 at 12:27
  • Updated the question. Added NGINX.conf and docker-compose.yml – Martin Müsli Jun 20 '20 at 13:01
  • 1. Try set the log config for nginx, `error_log /var/log/nginx/error.log info;` 2. ngx_stream_core is the one, defines groups of servers that can be referenced by the proxy_pass directive. From the docs >> `upstream backend { hash $remote_addr consistent; server backend1.example.com:12345 weight=5; server backend2.example.com:12345; server unix:/tmp/backend3; server backup1.example.com:12345 backup; server backup2.example.com:12345 backup; } server { listen 12346; proxy_pass backend; }` – abestrad Jun 20 '20 at 13:33
  • Did you ever get this figured out? I have the same problem. I am hosting gitea via docker-compose with SWAG as my reverse proxy but ssh doesn't work.. – Trevor Vance Jun 03 '21 at 20:43
  • I forgot about it. Wasn't needed for me. have you given @abestrad comment a chance? – Martin Müsli Jun 04 '21 at 12:38

0 Answers0