0

I am trying to setup my Nginx Web Server so that I have my main website which will be directed from domain.com and www.domain.com and then having a gitlab server install on the same server which can be accessed from git.domain.com.

I have my configs separated, so one for the main website and one for the gitlab instance.

Here are my configs currently:

Main Website:

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 Subdomain:

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


}

The Gitlab config is being read first from the naming of my configs.

However the issue I am having is that when ever I enter domain.com or www.domain.com into my web browser it always directs to the gitlab server instead of the main site.

I did have listen 80; in the configs too but I kept getting

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

Here is the config for my DNS:

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

What am I missing in my configs or have done incorrectly?

Lero
  • 150
  • 1
  • 2
  • 10
  • http://stackoverflow.com/questions/14972792/nginx-nginx-emerg-bind-to-80-failed-98-address-already-in-use – Luka Dec 29 '15 at 12:48
  • I had also tried that @Luka – Lero Dec 29 '15 at 12:50
  • When you say "the domain name" do you mean `http://domain.com` because you do not have a server_name for that name, so the implicit default_server will be used. – Richard Smith Dec 29 '15 at 12:52
  • @RichardSmith I mean when I go to my webbrowser and type in domain.com or www.domain.com I get the gitlab server. – Lero Dec 29 '15 at 12:57

0 Answers0