2

我是 nginx 新手。我正在尝试将 GitLabs 与当前由 Apache 在端口 80 上提供服务的现有 php 项目一起安装。我的计划是让它们在端口 90 上并排工作,然后关闭 Apache,将两个项目切换到端口 80 上的 Nginx .

好的。问题是这两个子域都被server我的 php 项目捕获,该项目应该只提供给db.mydomain.com. 对于 php 项目,我有一个名为:ccdbsymlinked into的文件/etc/nginx/sites-enabled。它包含:

server {
    server_name db.mydomain.com;
    listen  90; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www/ccdb;
    index index.html index.htm index.php;
}

/var/www/ccdb但是,出于某种原因,即使我有另一个文件与gitlab使用此内容调用的文件进行符号链接,但仍会从 git.mydomain.com 的流量中获取服务:

# GITLAB
# Maintainer: @randx
# App Version: 5.0

upstream gitlab {
    server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
    listen 90;         # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
    server_name git.mydomain.com;     # e.g., server_name source.example.com;
    server_tokens off;     # don't show the version number, a security best practice
    root /home/git/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;
    }
}

注意:我正在从同一本地网络上的 OSX 机器访问两个域,其/etc/hosts文件中有如下条目:

192.168.1.100 db.mydomain.com
192.168.1.100 git.mydomain.com
4

1 回答 1

0

尝试使用:

server_name git.mydomain.com:90;

... 和:

server_name db.mydomain.com:90;
于 2013-12-05T14:38:36.700 回答