• gitlab自带的Nginx与原Nginx冲突的解决方案


    gitlab

    推荐方案2

    默认情况下,gitlab使用自带的Nginx,占用80端口,这样就与系统原本安装的Nginx冲突。导致其中一个nginx无法启动

    我的gitlab可以正常启动,当再部署一个接口文档的项目时,发现原nginx无法启动,报错如下,

    [root@ACA83229 nginx]# service nginx restart
    Stoping nginx... nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
     failed. Use force-quit
    Terminating nginx...  done
    Starting nginx... nginx (pid 25521 25520 25519 25518 25517 25516 25515) already running.

    按照网上说的执行以下命令,并不能很好的解决问题。

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    后来想到可能是gitlab的Nginx冲突导致的,并成功解决

     

    方案一:通过修改GitLab端口解决冲突

    • vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
    upstream gitlab-workhorse {
      server unix:/var/opt/gitlab/gitlab-workhorse/socket;
    }
    
    server {
      listen *:80;  --修改端口
    
    
      server_name localhost;
      server_tokens off; ## Don't show the nginx version number, a security best practice
      ......
      ......
      只列举了其中一部分
    }

    将其中的80改为其它端口即可,如我的是8022,执行gitlab-ctl restart 重启gitlab等待网关恢复,重新访问:http://ip:8022 即可

    方案二:禁用gitlab自带Nginx 并把 UNIX套接字 更改为 TCP端口

    禁用捆绑的Nginx
    vim /etc/gitlab/gitlab.rb

    将
    nginx['enable'] = true
    修改为
    nginx['enable'] = false
    并去掉注释 (前边的#)

    允许gitlab-workhorse监听TCP(默认端口设置为8021),编辑/etc/gitlab/gitlab.rb:

    gitlab_workhorse['listen_network'] = "tcp"
    gitlab_workhorse['listen_addr'] = "127.0.0.1:8021"  //这个端口号一会和Nginx代理的端口号要一致

    运行 sudo gitlab-ctl reconfigure 使更改生效。

    • 通过系统原本安装的Nginx反代以便提供访问
    $ vim /usr/local/nginx/conf/vhost/gitlab.conf
    # 为原Nginx新建一个gitlab的配置文件
    server {
        listen       8022;  #我的gitlab一般使用8022端口访问
        server_name  localhost;
    
        location / {
            root  html;
            index index.html index.htm;
            proxy_pass http://127.0.0.1:8021; #这里与前面设置过的端口一致
        }
    }
    
    
    systemctl restart nginx  或者 service nginx restart 重启

    通过 172.168.50.41:8022 访问gitlab,一切OK

  • 相关阅读:
    JSTL日期格式化用法
    JSTL详解1
    Mybatis插入后返回主键
    JSTL详解2
    jsp与jsp之间传参数如何获取
    [转] J2EE面试题集锦(附答案)
    [转] 修炼一名程序员的职业水准(林庆忠原创)
    [转] 应聘Java笔试时可能出现问题及其答案(第三部分)
    [转] 与大家一起分享JAVA源代码查询网站
    [转] 应聘Java笔试时可能出现问题及其答案(第四部分)
  • 原文地址:https://www.cnblogs.com/lz0925/p/10879763.html
Copyright © 2020-2023  润新知