首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Docker中使用未绑定的Nginx和Wordpress运行Gitlab的问题

问在Docker中使用未绑定的Nginx和Wordpress运行Gitlab的问题
EN

Stack Overflow用户
提问于 2022-05-03 13:50:11
回答 1查看 155关注 0票数 0

我正试图在Docker中安装Gitlab和Wordpress与Nginx。我只能发布端口80和443,这就是为什么我希望使用未绑定的Nginx将发布在docker中的端口映射到(子)URL。我可以使用ssl访问Wordpress的域名,也可以访问其他带有郊区的码头容器,但我无法访问Gitlab。我已经尝试过多个Nginx和Gitlab设置,比如打开/关闭Gitlabs,以及external_url在gitlab.rb中的不同值,但我在下面的设置中只使用了一半。然而,每次我尝试登录时,我都会被重定向到wordpress,其url类似于my.domain.com/users/sign_in

这是我的设计:

代码语言:javascript
复制
version: '3.6'
services:
  git:
    image: gitlab/gitlab-ce:14.10.0-ce.0
    restart: unless-stopped
    container_name: gitlab
    hostname: 'my.domain.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
         gitlab_rails['gitlab_shell_ssh_port'] = 2224
         external_url 'http://127.0.0.1:8929/'
    ports:
      - "8929:80"
      - "2224:22"
    shm_size: '256m'
代码语言:javascript
复制
server {
  listen 80;
  listen [::]:80;

  server_name my.domain.com www.my.domain.com;


  location ~ /.well-known/acme-challenge {
    allow all;
    root /var/www/certbot;
  }


  location / {
    rewrite ^ https://$host$request_uri? permanent;
  }
}
server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  root /var/www/html;

  index index.php;

  server_name my.domain.com www.my.domain.com;

  server_tokens off;

  ssl_certificate /etc/nginx/ssl/live/my.domain.com/fullchain.pem;
  ssl_certificate_key /etc/nginx/ssl/live/my.domain.com/privkey.pem;


  location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$args;
  }

# WORDPRESS
  # pass the PHP scripts to FastCGI server listening on wordpress:9000
  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass wordpress:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  }
# GITLAB
  location /gitlab/ {
    gzip                    off;
    proxy_pass http://127.0.0.1:8929/;
  }
}

目标应该是这样的:

代码语言:javascript
复制
my.domain.com                 -> Wordpress        -> (directly setup together with nginx, therefore no ports published by wordpress-service)
my.domain.com/gitlab          -> Gitlab           -> Docker-Port: 8929:80, 2224:22
my.domain.com/something-else  -> Something-Else   -> Docker-Port: 9000:9000
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-03 15:25:46

在删除所有内容并执行新设置之后,我实际上让它运行,设置略有不同:

码头工人-组成Gitlab:

代码语言:javascript
复制
version: '3.6'
services:
  git:
    image: gitlab/gitlab-ce:14.10.0-ce.0
    restart: unless-stopped
    container_name: gitlab
    hostname: 'my.domain.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
         gitlab_rails['gitlab_shell_ssh_port'] = 2224
         external_url 'http://<host-ip-address>:<docker-gitlab-port>/gitlab/'
    ports:
      - "8929:8929" #doesn't work with 8929:80; no clue why though
      - "2224:2224"
    volumes:
      - /opt/gitlab/config:/etc/gitlab:rw
      - /opt/gitlab/data:/var/opt/gitlab:rw
    shm_size: '256m'

nginx.conf变化

代码语言:javascript
复制
location /gitlab/ {
    root /home/git/gitlab/public;
    
    proxy_http_version 1.1;
    proxy_pass http://<host-ip-address>:<docker-gitlab-port>/gitlab/;

    gzip                    off;

    #proxy_set_header    Host                $http_host; ##This one crashes everything (?)
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
  }

gitlab.rb

代码语言:javascript
复制
external_url 'http://<host-ip-address>:<docker-gitlab-port>/gitlab/'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72100426

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档