2012-11-05 2 views
6

에 gitlabhq 봉사의 nginx를 구성하는 방법 :gitlab에 대한 nginx를 구성하는 SubURI

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

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

server { 
    listen YOUR_SERVER_IP:80;   # e.g., listen 192.168.1.1:80; 
    server_name YOUR_SERVER_FQDN;  # e.g., 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; 
    } 
} 

내가이 surURI로 gitlab 제공하기 위해 무엇을 변경해야합니다, www.mysuperserver.com/gitlab

전 여러 가지 시도했지만 아무 것도 작동하지 않았습니다 감사합니다

답변

2

Gitlab 5.3부터는 공식 설치 문서를 사용하여 상자 밖으로 벗어나지 않고 실행할 수 있도록 구성 할 수 있습니다.

구성/puma.rb의 라인의 주석 8 ENV [ 'RAILS_RELATIVE_URL_ROOT'] = "/"/ gitlab.yml 설정 선 (23)에 대한 유사

: 가 relative_url_root/

I didn를 그것은 작동하도록 내 nginx 설정을 수정해야합니다.

1

이 문제는 아직 해결 되었습니까? ,에 location / 지시어를 업데이트하지 않으면

: 그 문제가 해결되지 않으면

location /gitlab { 
    # serve static files from defined root folder;. 
    root /home/gitlab/gitlab/public; 
    # @gitlab is a named location for the upstream fallback, see below 
    try_files $uri $uri/index.html $uri.html @gitlab; 
} 

, /var/log/nginx/gitlab_error.log의 마지막 몇 줄을 붙여주십시오.

+0

내가 가지고 원래의 질문과 비슷한 문제, 그리고 그것을 해결하는 방법을 시도했다. 내 오류 로그에는 새로운 항목이 없으므로이 문제만으로는 문제가 해결되지 않습니다. 내가하려는 것은 http://unicorn.bogomips.org/examples/nginx.conf와 같은 것에 당신의 제안을 적용하는 것이다. –

-1

이 구성

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

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

server { 
    listen 80;   # e.g., listen 192.168.1.1:80; 37.59.125.28: 
    server_name gitlab.<YOUR_DOMAIN>.com;  # e.g., 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; 
    } 
} 

작동 그리고 난 nginx를 사용할 수 구성 및 활성화 구성 사이 나쁜 심볼릭 링크를했다.

+0

귀하의 설정과 귀하의 질문에서 하나의 차이점을 보는 데 어려움을 겪고 있습니다 (서버 이름 제외). 'www.mysuperserver.com/gitlab'을 허용하는 부분은 어디 있습니까? – VonC

+0

위의 설정은 하위 도메인에 대한 것으로 보입니다. 내 대답은, 테스트를 거치지 않았지만, 질문을 받았을 때, 'www.mysuperserver.com/gitlab'에서 작동해야합니다. 누구나 시도하면 확인을하는 것이 좋습니다. – myanimal

3

성공적으로 subdir url로 작업하게했습니다.

:

  • 가 suburi를 제공하기 /home/git/gitlab/config/gitlab.yml
 
    # Uncomment and customize the last line to run in a non-root path 
    # WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this. 
    # Note that four settings need to be changed for this to work. 
    # 1) In your application.rb file: config.relative_url_root = "/gitlab" 
    # 2) In your gitlab.yml file: relative_url_root: /gitlab 
    # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" 
    # 4) In ../gitlab-shell/config.yml: gitlab_url: "http://127.0.0.1/gitlab" 
    # To update the path, run: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production 
    # 
    relative_url_root: /gitlab 
  • 변경의 nginx의 설정처럼, 소스 코드의 지시 사항을 따르 PLZ 아래에있는 내 예를 참조 핵심은 serveralias 아래 root이며입니다.3210. 자세한 내용은 nginx pitfalls, nginx root note을 참조하십시오. 이전 버전의

    # default.conf for nginx 
    upstream gitlab { 
        server unix:/home/git/gitlab/tmp/sockets/gitlab.socket; 
    } 
    server { 
        listen  80; 
        server_name $YOUR_DOMAIN; 
        # other settings, especially root settings, like below 
        # root /usr/local/nginx/html; 
        location /gitlab { 
         # serve static files from defined root folder; 
         alias /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; 
    
         # @gitlab is a named location for the upstream fallback, see below 
         try_files $uri $uri/index.html $uri.html @gitlab; 
        } 
    
        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_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    
         proxy_pass http://gitlab; 
        } 
        # other locations' settings... 
    } 
    
+1

+1. GitLab의 어떤 버전을 사용 했습니까? push/pull ssh url로 테스트 했습니까? https URL? – VonC

+0

브랜치는 '6-4-stable'이다. 아무도 밀기/당기기에 대해 불평하지 않습니다. 아직 https URL을 설정하지 않았습니다. – Ace

2

는, 예를 들어, gitlab 7.4.5, 더 gitlab - 자식-HTTP 서버 (gitlab-주력)이 없습니다. 그러나 gitlab 7.4.5가 문서에서 suburi를 사용하기위한 몇 가지 해결책이 있습니다.

config/gitlab.yml

# WARNING: See config/application.rb under "Relative url support" for the list of 
# other files that need to be changed for relative url support 
# relative_url_root: /gitlab 

# Relative url support 
# Uncomment and customize the last line to run in a non-root path 
# WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this. 
# Note that following settings need to be changed for this to work. 
# 1) In your application.rb file: config.relative_url_root = "/gitlab" 
# 2) In your gitlab.yml file: relative_url_root: /gitlab 
# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" 
# 4) In ../gitlab-shell/config.yml: gitlab_url: "http://127.0.0.1/gitlab" 
# 5) In lib/support/nginx/gitlab : do not use asset gzipping, remove block starting with "location ~ ^/(assets)/" 
# 
# To update the path, run: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production 
# 
# config.relative_url_root = "/gitlab" 

config/application.rb

는 gitlab 7.4을 구성.5 다른 웹 사이트와 같은 포트와 동일한 도메인 이름을 nginx 구성 또는 아파치 구성 파일을 사용하여 5 여전히 도전 보인다. 나는 이것을 얻지 못했다. www.mydomain.com/gitlab으로 gitlab에 액세스 할 수 있지만 www.mydomain.com을 사용하여 다른 루트 디렉토리에 다른 웹 사이트를 가져 오지 못했습니다. configure nginx 또는 apache에 의해 거부되어야합니다. nginx 나 apache에 익숙한 사람들이 해결책을 줄 수 있기를 바랍니다.

기타 참조 자료. Support installing GitLab in a relative URL path or sub directory #1950

편집
그것은 작동합니다.

stackoverflow 여기 예제로 www.example.com을 사용하는 것이 좋습니다.

www.example.com/gitlab 액세스 gitlab

www.example.com 다른 웹 사이트 (예 : 내 블로그)에 액세스하십시오.

단계 :

  1. 설정/application.rb 파일 : config.relative_url_root = "/ gitlab"
  2. 설정/gitlab.yml 파일 : relative_url_root :/gitlab
  3. 설정/unicorn.rb : ENV [ 'RAILS_RELATIVE_URL_ROOT'] = "/ gitlab"
  4. ../gitlab-shell/config.yml : gitlab_url : /의 nginx/gitlab "http://www.example.com/gitlab"
  5. 복사 lib 디렉토리/지원의 nginx에 대한 gitlab.conf하고 자산을 사용하지 않는 gzipping, 블록 별 삭제 팅 "location ~^/(assets)/"
  6. 실행과 : sudo는 -u 자식 -H 간부 레이크 자산 번들 : 사전 컴파일 RAILS_ENV을 = 생산

의 URL :

  1. 설정/gitlab.yml 파일 : 호스트 : example.com 포트 : 80
  2. 설정/unicorn.rb : 수신 "127.0.0.1:9095"
  3. ../gitlab-shell/config.yml : gitlab_url : http://www.example.com/gitlab
  4. ,451,515,

gitlab 액세스에 자식에게 두 가지 방법을 제공합니다 :

  1. [email protected]을 : 샘플 project.git
  2. http://example.com/gitlab/sample-project.git

내가 HTTPS를 사용하고 있지 않다.

당신이 가지고있는 경우 :

을 당신은 host: example.com/gitlabconfig/gitlab.yml을 구성 할 수 있습니다. /gitlab을 삭제하면됩니다.

의 nginx 구성 파일 :

################################### 
##   configuration   ## 
################################### 
## 

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

## Normal HTTP host 
server { 
    #listen *:80 default_server; 
    listen *:80 default_server; 
    server_name www.example.com; ## Replace this with something like gitlab.example.com 
    server_tokens off; ## Don't show the nginx version number, a security best practice 
    #root /home/git/gitlab/public; 
    root html; 
    location /{ 
    #root html; 
    index index.html index.htm; 
    } 
    ## Increase this if you want to upload large attachments 
    ## Or if you want to accept large git objects over http 
    client_max_body_size 20m; 

    ## Individual nginx logs for this GitLab vhost 
    access_log logs/example.gitlab_access.log; 
    error_log logs/example.gitlab_error.log; 

    location /gitlab { 
    alias /home/git/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 passes the request to the upsteam (gitlab unicorn). 
    location @gitlab { 
    ## If you use HTTPS make sure you disable gzip compression 
    ## to be safe against BREACH attack. 
    # gzip off; 

    ## https://github.com/gitlabhq/gitlabhq/issues/694 
    ## Some requests take more than 30 seconds. 
    proxy_read_timeout  300; 
    proxy_connect_timeout 300; 
    proxy_redirect   off; 

    proxy_set_header Host    $http_host; 
    proxy_set_header X-Real-IP   $remote_addr; 
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $scheme; 
    proxy_set_header X-Frame-Options  SAMEORIGIN; 

    proxy_pass http://gitlab; 
    } 

    ## Enable gzip compression as per rails guide: 
    ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression 
    ## WARNING: If you are using relative urls remove the block below 
    ## See config/application.rb under "Relative url support" for the list of 
    ## other files that need to be changed for relative url support 
    #location ~ ^/(assets)/ { 
    # root /home/git/gitlab/public; 
    # #gzip_static on; # to serve pre-gzipped version 
    # expires max; 
    # add_header Cache-Control public; 
    #} 

    error_page 502 /502.html; 
} 

아파치 (2.2.9) 구성 파일을 참조 gitlab.conf gitlab 8.0.0에 대한 gitlab 6.0.6 및 gitlab-8.0-apache2.2.conf에 대한 아파치 2.2

# Module dependencies 
# mod_rewrite 
# mod_proxy 
# mod_proxy_http 
<VirtualHost *:80> 


    ServerAdmin [email protected] 
    DocumentRoot "/data/webapp/www/wordpress" 

    ServerName www.example.com 
    ServerAlias example.com 

    #ErrorLog "logs/wordpress-error_log" 
    #CustomLog "logs/wordpress-access_log" common 

    #SetEnv ZF2_PATH "/data/webapp/www/ZendFramework-2.3.3/library" 
    SetEnv APPLICATION_ENV "development" 
    <Directory /data/webapp/www/wordpress> 
    DirectoryIndex index.php 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
    </Directory> 

    #ServerName www.example.com 
    ServerSignature Off 

    ProxyPreserveHost On 

    # Ensure that encoded slashes are not decoded but left in their encoded state. 
    # http://doc.gitlab.com/ce/api/projects.html#get-single-project 
    AllowEncodedSlashes NoDecode 

    <Location /gitlab> 
    Order deny,allow 
    Allow from all 

    ProxyPassReverse http://127.0.0.1:9095 
    ProxyPassReverse http://www.example.com// 

    RewriteEngine on 
    #RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
    RewriteRule .* http://127.0.0.1:9095%{REQUEST_URI} [P,QSA,NE] 
    </Location> 

    #apache equivalent of nginx try files 
    # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files 
    # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab 
    # RewriteEngine on 
    # RewriteCond /code/gitlab/{REQUEST_FILENAME} !-f 
    # RewriteRule .* http://127.0.0.1:9095%{REQUEST_URI} [P,QSA,NE] 

    # needed for downloading attachments 
    #DocumentRoot /home/git/gitlab/public 
    Alias /gitlab /home/git/gitlab/public 
    #Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up. 
    ErrorDocument 404 /404.html 
    ErrorDocument 422 /422.html 
    ErrorDocument 500 /500.html 
    ErrorDocument 503 /deploy.html 

    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded 
    ErrorLog logs/example.com_error.log 
    CustomLog logs/example.com_forwarded.log common_forwarded 
    CustomLog logs/example.com_access.log combined env=!dontlog 
    CustomLog logs/example.com.log combined 

</VirtualHost> 
관련 문제