Ehs*_*jad 3 nginx gitlab docker
我正在尝试将 nginx 设置为反向代理,以路由apps.mycompany.com/gitlab
到与 nginx 在同一服务器上运行的 gitlab docker 容器:
nginx 配置有:
location /gitlab/ {
proxy_pass http://127.0.0.1:3000/;
proxy_redirect default;
}
Run Code Online (Sandbox Code Playgroud)
第一个 http 调用apps.mycompany.com/gitlab
进行得很顺利,但基本上 html 内的所有 href(例如href:"/assets/..."
)仍然路由到apps.mycompany.com/assets/...
而不是apps.mycompany.com/gitlab/assets/...
所以没有找到assets和css文件。渲染的页面有结构,但没有样式,我什至不知道还有什么不起作用。
我对 nginx 不太了解,不知道我做错了什么
NGINX
在您的 nginx 配置中添加proxy_set_header
选项并进行proxy_pass
如下更改:
location /gitlab/ {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3000/gitlab/;
}
Run Code Online (Sandbox Code Playgroud)
GITLAB
您正在寻找的是GitLab 中的相对 URL配置。
如果您的 GitLab 版本为8.5或更高版本,请根据您的 GitLab 部署类型执行以下操作之一:
DOCKER-COMPOSE 部署
将环境变量添加external_url
到您的docker-compose.yml
文件中,示例文件:
gitlab:
image: 'gitlab/gitlab-ce:11.5.2-ce.0'
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://apps.mycompany.com/gitlab/'
ports:
- '3000:80'
Run Code Online (Sandbox Code Playgroud)
然后重新启动 GitLab docker:
docker-compose up -d
DOCKER部署
如果您没有使用 docker-compose (我强烈推荐),那么您可以external_url
向docker run
命令添加选项,示例执行:
docker run --detach --publish 3000:80 --restart always --env GITLAB_OMNIBUS_CONFIG="external_url 'http://apps.mycompany.com/gitlab/'" gitlab/gitlab-ce:11.5.2-ce.0
GitLab 配置文件更新 - 可用于各种部署
另一种方法是直接修改 GitLab 配置文件,但我建议对于独立的 GitLab 安装而不是 docker 部署。
修改 GitLab 配置,将值/etc/gitlab/gitlab.rb
更改external_url
为以下:
external_url "http://apps.mycompany.com/gitlab"
进行此更改后,您必须重新配置 GitLab:
sudo gitlab-ctl reconfigure
然后重启服务:
sudo gitlab-ctl restart
您可以在官方文档中找到有关 GitLab 配置的更多详细信息。
我建议您还查看 docker 部署官方文档中的 GitLab 。
请注意,Omnibus GitLab 中的相对 URL 支持是实验性的,在版本 8.5 中引入(对于早期版本,您需要从源代码 - doc进行编译)。
归档时间: |
|
查看次数: |
3514 次 |
最近记录: |