我已经在虚拟机中的一个Ubuntu(12.04)虚拟机上安装了gitlab,在我的NAS上(在Windows 7上)
这台机器的主机名是vubuntu。 我的路由器(番茄v1.28)被configuration为使用.lan域名。
在我的工作站上,我可以使用地址vubuntu.lan成功ping通虚拟机
nginx中gitlab的configuration文件与安装文档中给出的一样,除了我更改了listen和server_name参数:
# Maintainer: @randx # App Version: 4.0 upstream gitlab { server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; } server { listen 192.168.0.5:80; # eg, listen 192.168.1.1:80; server_name gitlab.vubuntu; # eg, server_name source.example.com; root /home/gitlab/gitlab/public; # 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; } }
问题是,当我在浏览器中访问http://gitlab.vubuntu.lan/时,说它找不到页面。
但是,如果我访问http://vubuntu.lan/ ,我有gitlab页面。
我如何才能使用子域访问gitlab?
谢谢!
首先,您需要在您的路由器(或您的主机文件,尽pipe路由器是一个更好的地方)添加一个DNSlogging,指出该子域到虚拟机。
其次,看起来nginx正在监听该IP地址上的所有请求,而不pipe它们的地址如何,因为你只有一个configuration块。 从这个问题 ,你可以看到,nginx只查看主机头来确定连接build立后的子域。 如果为server_name vubuntu;添加另一个块server_name vubuntu; ,您应该不再能够通过vubuntu.lan进入gitlab站点。