[英]docker-compose to a remote host using ssh fails in gitlab ci
[英]docker-compose gitlab with Nginx but ssh failed
我使用 docker-compose 在 GCP 上的同一台服务器上构建 Nginx 和 gitlab。 And I am using Cloudflare to manage my DNS, I have a domain name gitlab.mydomain.com
which is binding with my GCP static IP (for example my ip is 123.45.67.89
).
所以我想用这个域来访问我的gitlab和Nginx,下面是我的docker-compose.yml
文件:
version: '3.5'
services:
gitlab:
image: gitlab/gitlab-ce:latest
container_name: gitlab
restart: always
hostname: 'gitlab.mydomain.com'
privileged: true
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.mydomain.com:7788'
gitlab_rails['gitlab_shell_ssh_port'] = 9453
ports:
- '7788:80'
- '9453:22'
volumes:
- /gitlab/data:/var/opt/gitlab
- /gitlab/logs:/var/log/gitlab
- /gitlab/config:/etc/gitlab
networks:
- net-proxy
nginx:
image: nginx
container_name: nginx
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
networks:
net-porxy:
external:
name: my-network
这是我的Nginx.conf
文件:
server {
listen 80;
server_name gitlab.mydomain.com;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
location ~ / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://123.45.67.89:7788;
}
}
我还在我的gitlab.rb
文件中添加了这一行
external_url 'http://gitlab.mydomain.com'
I changed my ssh port from 22 to 9453 port, and I can access my gitlab service by my domain gitlab.mydomain.com
, and I can also clone my git repo with http, but when I want to clone with ssh
git clone ssh://git@gitlab.mydomain.com:9453/myproject/myrepo.git
, it will always show operation time out.
但是,如果我用 ip 替换我的 ssh 域:
git clone ssh://git@123.45.67.89:9453/myproject/myrepo.git
成功了!!!
我不确定这是否是因为我的域是 Nginx 的反向代理。 如果我想用 Nginx 按域克隆我的仓库,请问我该怎么做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.