gpt4 book ai didi

nginx - 通过Jwilder的Nginx代理访问虚拟主机时出现502错误网关

转载 作者:行者123 更新时间:2023-12-02 21:26:47 24 4
gpt4 key购买 nike

我有一个Nginx代理(Jwilder,默认配置)和Gitlab实例在同一主机上运行。git.myhost.com指向主机IP。
当使用下面的docker-compose.yml启动Gitlab时,访问http://git.myhost.com时会得到一个502 Bad Gateway

在nginx-proxy容器中生成的/etc/nginx/conf.d/default.conf也看起来不错:

upstream git.myhost.com {
# 2ab9168d-c69e-4725-8c20-31a194ad8d07
server 172.17.0.13 vhost;
}
server {
server_name git.myhost.com;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass http://git.myhost.com;
}
}

我在做什么错?

这是Gitlab的 docker-compose.yml:
gitlab-server:
hostname: git.myhost.com
expose:
- "8100"
ports:
- 8101:22/tcp
# - 8100:8100/tcp
labels:
io.rancher.sidekicks: gitlab-data
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://git.myhost.com'
gitlab_rails['gitlab_shell_ssh_port'] = 8101
VIRTUAL_HOST: git.myhost.com
VIRTUAL_PORT: 8100
image: gitlab/gitlab-ce:latest
volumes_from:
- gitlab-data

gitlab-data:
labels:
io.rancher.container.start_once: 'true'
entrypoint:
- /bin/true
hostname: gitdata
image: gitlab/gitlab-ce:latest
volumes:
- /etc/gitlab:/etc/gitlab
- /var/log/gitlab:/var/log/gitlab
- /var/opt/gitlab:/var/opt/gitlab

最佳答案

您应该按以下方式更改nginx:

upstream gitlab {
# 2ab9168d-c69e-4725-8c20-31a194ad8d07
server 172.17.0.13:8100;
}
server {
server_name git.myhost.com;
listen 80 ;
access_log /var/log/nginx/access.log vhost;
location / {
proxy_pass http://gitlab;
}
}

172.17.0.13是gitlab docker容器的IP地址。

关于nginx - 通过Jwilder的Nginx代理访问虚拟主机时出现502错误网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36445551/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com