如何在nginx上设置子域名?

我已经在下面的path/home/git/gitlab/设置了我的unbuntu ubuntu 12.04 lts服务器上的GitLab 。 我正在使用nginx服务器。
这是我的gitlab状态

 root@c27-76:/etc# sudo service gitlab status The GitLab Unicorn web server with pid 3187 is running. The GitLab Sidekiq job dispatcher with pid 3197 is running. GitLab and all its components are up and running. 

我无法为gitlab设置子域。 我想要一个像gitlab.domain.com这样的域名。

这是我在/ etc / nginx / sites-avaliable上的gitlab文件

 server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 root /home/git/gitlab/; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name gitlab.ecut.eu; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; allow ::1; deny all; } Nothings happens when i restart nginx. 

这是我的etc/hosts文件

 127.0.0.1 localhost.localdomain ecut.eu ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 127.0.0.1 startup2014.eu localhost startup2014.eu 127.0.0.1 gitlab.ecut.eu localhost gitlab.ecu.eu # Auto-generated hostname. Please do not remove this comment. 217.146.76.27 c27-76.uvn.zone.eu c27-76 

请build议我如何解决这个问题。

谢谢你,克里希纳

这是我工作的gitlab的nginxconfiguration。 如果指定为server_name子域名应该可以正常工作。

正如@ eric-dannielou提到的检查,以便/etc/nginx/sites-available/gitlab/etc/nginx/sites-enabled /etc/nginx/sites-available/gitlab链接:

ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

在/ etc / nginx的/网站可用/ gitlab

 # GITLAB # Maintainer: @randx # App Version: 5.0 upstream gitlab { server unix:/home/git/gitlab/tmp/sockets/gitlab.socket; } server { listen 80 default_server; # eg, listen 192.168.1.1:80; In most cases *:80 is a good idea server_name git.domain.com; # eg, server_name source.example.com; server_tokens off; # don't show the version number, a security best practice root /home/git/gitlab/public; client_max_body_size 500m; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { # serve static files from defined root folder;. # @gitlab is a named location for the upstream fallback, see below try_files $uri $uri/index.html $uri.html @gitlab; } # if a file, which is not found in the root folder is requested, # then the proxy pass the request to the upsteam (gitlab unicorn) location @gitlab { proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://gitlab; } }