网站首页 > 教程文章 正文
搭建gitlab自定义域名
Gitlab 内置了 nginx,所以配置nginx代理服务器转向GitLab内置的nginx
参见官网:
https://docs.gitlab.com/omnibus/settings/configuration.html#
configuring-the-external-url-for-gitlab
配置Gitlab
编辑GitLab配置文件
vim /etc/gitlab/gitlab.rb修改端口监听
nginx['listen_port'] = 8800修改Gitlab域名
external_url 'http://www.example.com'使配置生效
## 配置生效
sudo gitlab-ctl reconfigureo
## 重启
gitlab-ctl restart配置nginx
配置内容如下
server{
listen 80;
# 外网访问域名,此域名是提供给最终用户的访问地址
server_name 域名;
location / {
# 客户端请求正文的最大允许大小
# 这个大小的非常重要,如果git版本库里有大文件,设置的太小,文件push会失败,根据情况调整
client_max_body_size 50m;
# 安全相关 header
# 禁止网站被嵌入到其它网页中,如:iframe、embed等,SAMEORIGIN表示该页面仅能在相同域名页面的iframe中展示
add_header X-Frame-Options "SAMEORIGIN" always;
# 当检测到XSS攻击时阻止页面加载
add_header X-XSS-Protection "1; mode=block" always;
# 禁止请求类型为style和script时,但MIME类型却不为text/css和JavaScript的请求
add_header X-Content-Type-Options "nosniff" always;
proxy_redirect off;
#以下确保 gitlab中项目的 url 是域名而不是 http://git,不可缺少
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 反向代理到 gitlab 内置的 nginx
proxy_pass http://www.example.com:8800;
index index.html index.htm;
}
# 防止爬虫抓取
if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot") {
return 403;
}
}重载nginx
sudo /usr/local/nginx/sbin/nginx -t
sudo /usr/local/nginx/sbin/nginx -s reload
或
sudo systemctl reload nginx配置GitLab项目默认域名
编辑gitlab.yml配置文件
vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml修改如下内容
gitlab:
## HTTP/S方式拉取项目时的域名
host: http://www.example.com
port: 80
https: false
## SSH方式拉取项目时的域名
ssh_host: www.example.com其它
安装GitLab
迁移/备份/恢复GitLab
修改GitLab的root用户密码
未完待续
猜你喜欢
- 2025-10-08 从0到1,Docker安装中文版Gitlab服务端
- 2025-10-08 Centos下安装gitlab_centos下安装gcc
- 2025-10-08 私有化部署代码仓库 GitLab:从介绍到实践
- 2025-10-08 再见Github和码云!基于Linux安装私有化部署GitLab代码仓库
- 2025-10-08 gitlab代码管理工具好用吗?怎么下载?
- 2025-10-08 centos7下搭建git和gitlab版本库_centos7 git安装
- 2025-10-08 作为前端你必须要会的CICD_前端 cicd
- 2025-10-08 宝塔GitLab的安装踩坑_宝塔安装gitea
- 2025-10-08 CentOS安装部署GitLab服务器_centos如何安装git
- 2025-10-08 如何在CentOS7上搭建自己的GitLab仓库
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- mybatis plus page (35)
- vue @scroll (38)
- 堆栈区别 (33)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)
- redis aof rdb 区别 (33)
- 302跳转 (33)
- http method (35)
- js array splice (33)
