Ubuntu Nginx gitlab子域和www

Ubuntu Nginx gitlab子域和www,ubuntu,nginx,dns,gitlab,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; ind

我正在尝试设置我的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;
}
}
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子域:

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;
}
}
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配置

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

我确实听了
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

我的配置中缺少了什么或做得不正确?

我也试过@lukaw当你说“域名”时,你是指
http://domain.com
因为您没有该名称的服务器名称,因此将使用隐式默认的_服务器。@RichardSmith我的意思是,当我转到我的webbrowser并键入domain.com或www.domain.com时,我会得到gitlab服务器。