0

在 docker-compose 中使用反向代理 (NGINX) 设置 Gitea 实例对我来说效果很好。登录到 web 应用程序后,创建存储库、更改设置等工作。甚至可以通过 HTTPS 克隆存储库。但是,通过 SSH 克隆会遇到

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.

我如何确定问题的过程?docker-compose 日志只显示

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

这对我没有帮助。

代码 docker-compose 文件和我的 nginx 配置可以通过我的GitHub 存储库访问

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;
    }
  }
}

4

0 回答 0