我是nginx的新手。我正在尝试将GitLabs与现有的php项目一起安装,该项目目前由Apache在端口80上提供服务。我的计划是让它们在端口90上并排工作,然后关闭Apache,在端口80上将两个项目切换到Nginx
好。问题是我的php项目server
正在捕获这两个子域,这些子域只应该提供给db.mydomain.com
的请求。对于php项目,我有一个名为ccdb
符号链接到/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;
}
但是,出于某种原因,git.mydomain.com的流量正在从/var/www/ccdb
获得服务,即使我有另一个符号链接的文件与名为gitlab
的文件一起使用此内容:
# 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
答案 0 :(得分:0)
尝试使用:
server_name git.mydomain.com:90;
......和:
server_name db.mydomain.com:90;