我有一个问题,试图configurationNginx
与gitlab
和我有一些其他网站的工作。
我有foo.com指向我的服务器。 bar.foo.com也指向我的服务器。 我想在bar.foo.com上有gitlab ,而在foo.com上有另一个网站
我想我可以很容易地做到这一点使用服务器块和server_names,但这似乎并不正确。
我试着做的是定义3个不同的服务器块,用不同的服务器名称。 但是这不起作用。 发生什么事是,当我尝试访问foo.com
我结束了bar.foo.com
这是gitlab。
不pipe我尝试做什么,我总是在gitlab上结束。 所以我想,也许根应该进入位置文件夹,但这似乎并没有改变任何东西。
在我的网站启用,我目前有3个文件:gitlab,website1和website2
任何帮助,将不胜感激。
这里是gitlab
configuration文件
upstream gitlab { server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; } server { listen 80; # eg, listen 192.168.1.1:80; server_name bar.foo.com www.bar.foo.com; # 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 / { root /home/gitlab/gitlab/public; # 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 { root /home/gitlab/gitlab/public; 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; } }
这是第二个文件:
server { listen 80; server_name foo.com www.foo.com; index index.html index.htm; #root /var/www/users; location / { root /var/www/users; try_files $uri $uri/ /index.html; } }
第三个文件与第二个文件非常相似,所以病没有打扰。