Nginx gitlab子域名和www

时间:2015-12-29 12:29:38

标签: ubuntu nginx dns gitlab

我正在尝试设置我的Nginx Web服务器,以便我的主网站将从domain.com和www.domain.com定向,然后在同一台服务器上安装gitlab服务器,可以从git访问.domain.com。

我将我的配置分开,所以一个用于主网站,一个用于gitlab实例。

以下是我的配置:

主要网站:

server {
listen [::]:80;
server_name *.domain.com www.domain.com;
root /home/domain.com/public;
index index.php index.html index.htm;


location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
}

Gitlab子域名:

upstream gitlab-workhorse {
 server unix:/var/opt/gitlab/gitlab-workhorse/socket;
}


server {
 listen [::]:80;

 server_name git.domain.com;
 server_tokens off; ## Don't show the nginx version number, a security                             best practice
 root /opt/gitlab/embedded/service/gitlab-rails/public;

 ## Increase this if you want to upload large attachments
 ## Or if you want to accept large git objects over http
 client_max_body_size 0;


 ## Individual nginx logs for this GitLab vhost
 access_log  /var/log/gitlab/nginx/gitlab_access.log;
 error_log   /var/log/gitlab/nginx/gitlab_error.log;

location / {
  ## If you use HTTPS make sure you disable gzip compression
  ## to be safe against BREACH attack.
  ## https://github.com/gitlabhq/gitlabhq/issues/694
  ## Some requests take more than 30 seconds.
  proxy_read_timeout      300;
  proxy_connect_timeout   300;
  proxy_redirect          off;

  proxy_http_version 1.1;

  proxy_set_header    Host                $http_host;
  proxy_set_header    X-Real-IP           $remote_addr;
  proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
  proxy_set_header    X-Forwarded-Proto   http;

  proxy_pass http://gitlab-workhorse;
 }


}

首先从我的配置命名中读取Gitlab配置。

然而我遇到的问题是,当我将domain.com或www.domain.com输入我的网络浏览器时,它总是指向gitlab服务器而不是主站点。

我在配置中确实有listen 80;,但我一直在

bind() to 0.0.0.0:80 failed (98: Address already in use)

以下是我的DNS配置:

A domain.com xxx.xxx.xxx.xxx
CNAME www.domain.com domain.com
CNAME git.domain.com domain.com

我的配置中缺少什么或做错了什么?

0 个答案:

没有答案