2013-04-14 1 views
1

Nginx로 내 서버에서 Gitlab을 실행하고 있으며 git.mysite.com에서 완벽하게 실행 중입니다. 그러나 루트 도메인에 액세스 할 때/usr/share/nginx/www에 index.html 파일을 표시하는 대신/home/gitlab/gitlab에 Gitlab이 표시됩니다.서브 도메인의 내용을 루트 도메인으로 표시하는 Nginx

어떻게 해결할 수 있습니까?

기본 (을/etc/nginx를/사이트-가능/기본)

server { 
    listen 80; ## listen for ipv4; this line is default and implied 
    #listen [::]:80 default ipv6only=on; ## listen for ipv6 

    root /usr/share/nginx/www; 
    index index.php index.html index.htm; 

    server_name mysite.com; 

    location/{ 
     try_files $uri $uri/ /index.html; 
    } 

    location /doc/ { 
     alias /usr/share/doc/; 
     autoindex on; 
     allow 127.0.0.1; 
     deny all; 
    } 

    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/www; 
    } 

    location ~ \.php$ { 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 
    location ~ /\.ht { 
     deny all; 
    } 
} 

gitlab (을/etc/nginx를/사이트-가능/gitlab)

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

server { 
    listen 198.199.70.76:80 default_server; 
    server_name git.mysite.com; 
    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; 
    } 
} 

답변

2

default_server 대신 포트 80을 수신 대기하도록 하위 도메인을 변경하려고합니다.

listen 80; 

대신 :

listen 198.199.70.76:80 default_server; 
이 줄을 사용해보십시오
0

두 설정은 포트에서 청취 80 및 gitlab one (Gitlab Repo로 이동 한 Gitlab recipe에서 곧바로 : gitlab.com/gitlab-org/gitlab-ce/lib/support/nginx/gitlab)은 GitLab 서버에 '/'부터 액세스합니다. http://198.199.70.76:80/은 GitLab을 반환합니다.

198.199.70.76으로 확인되지 않는 쿼리 만 첫 번째 구성 (index.html)을 사용합니다.
예를 들어 서버에서 실행하면 http://localhost/이 작동합니다.

관련 문제