2012-11-05 10 views
6

Die nginx-Konfiguration für Gitlab dienen gitlabhq ist:Wie nginx konfigurieren, dass ein 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; 
    } 
} 

Was soll ich als Sururi www.mysuperserver.com/gitlab i, dienen Gitlab ändern

habe viele verschiedene dinge ausprobiert, aber nichts hat funktioniert danke

Antwort

2

Ab Gitlab 5.3 können Sie es so konfigurieren, dass es mit dem offiziellen Installationsdokument in einem Suburi Out-of-the-Box ausgeführt wird.

Uncomment Zeile 8 der config/puma.rb: ENV [ 'RAILS_RELATIVE_URL_ROOT'] = "/"

Ähnliches gilt für die Leitung 23 in config/gitlab.yml: relative_url_root:/

I didn Ich muss meine nginx-Konfiguration überhaupt nicht ändern, damit sie funktioniert.

1

Haben Sie dieses Problem schon gelöst?

Wenn nicht, versuchen Sie die location / Aktualisierung der Richtlinie zu:

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; 
} 

Wenn das nicht funktioniert, fügen Sie bitte die letzten Zeilen von /var/log/nginx/gitlab_error.log.

+0

Ich habe ein ähnliches Problem zu der ursprünglichen Frage, und ich versuchte Ihren Ansatz, es zu lösen. Mein Fehlerprotokoll enthält keine neuen Einträge und es scheint, dass dies allein das Problem nicht löst. Was ich versuche, ist, deinen Vorschlag auf etwas wie dieses anzuwenden: http://unicorn.bogomips.org/examples/nginx.conf. –

-1

Diese Konfiguration funktioniert

# 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; 
    } 
} 

Und ich hatte eine schlechte symbolische Verbindung zwischen nginx verfügbar Konfiguration und der Konfiguration aktiviert.

+0

Es fällt mir schwer, den Unterschied zwischen Ihrer Konfiguration und der in Ihrer Frage zu sehen (außer dem Servernamen). Wo ist der Teil, der "www.mysuperserver.com/gitlab" erlaubt? – VonC

+0

Die obige Konfiguration scheint für eine Sub-Domain zu sein. Meine Antwort, obwohl nicht getestet, sollte für die Frage funktionieren, wie sie gefragt wurde: "www.mysuperserver.com/gitlab". Wenn jemand es versucht, wäre es gut, eine Bestätigung zu bekommen. – myanimal

3

Ich habe es erfolgreich unter einer Subdir-URL funktioniert.

  • die Anweisung im Quellcode folgen, wie in /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 
  • die nginx Konfigurationsänderung eine suburi zu dienen, plz zu meinem Beispiel siehe unten:

Der entscheidende Punkt ist der root unter Kontext server und alias unter location. Plz beziehen sich auf nginx pitfalls, nginx root note für weitere Details.

# 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. Welche Version von GitLab hast du benutzt? Hast du es mit Push/Pull ssh url getestet? https URL? – VonC

+0

Zweig '6-4-stabil'. Niemand beklagt sich über den Push/Pull. noch nicht die https url einrichten. – Ace

2

Für alte Versionen, zum Beispiel Gitlab 7.4.5 gibt es keinen Gitlab-git-http-Server (Gitlab-Arbeitspferd). Aber es gibt einige Lösungen für gitlab 7.4.5, Suburi im Doc zu verwenden.

config/application.rb

# 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/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 

konfigurieren Gitlab 7.4.5 mit anderen Webseiten, die denselben Port und denselben Domainnamen in einer nginx-Konfiguration oder Apache-Konfigurationsdatei verwenden, scheint immer noch eine Herausforderung zu sein. Ich habe das nicht verstanden. Ich kann auf Gitlab als www.mydomain.com/gitlab zugreifen, aber ich habe meine andere Website in einem anderen Stammverzeichnis mit www.mydomain.com nicht bekommen. Es sollte von Nginx oder Apache konfiguriert werden. Hoffnung Leute, die mit Nginx oder Apache vertraut sind, können eine Lösung geben.

Andere Referenzen. Support installing GitLab in a relative URL path or sub directory #1950

EDIT
Es funktioniert jetzt.

stackoverflow schlagen vor, www.example.com als Beispiel hier zu verwenden.

www.example.com/gitlab Zugriff gitlab.

www.example.com Zugriff auf eine andere Website, sagen wir, mein Blog.

Schritte:

  1. config/application.rb Datei: config.relative_url_root = "/ Gitlab"
  2. config/gitlab.yml Datei: relative_url_root:/Gitlab
  3. config/unicorn.rb: ENV [ 'RAILS_RELATIVE_URL_ROOT'] = "/ Gitlab"
  4. ../gitlab-shell/config.yml: gitlab_url: "http://www.example.com/gitlab"
  5. Kopie lib/support/nginx/Gitlab für nginx gitlab.conf und verwenden Sie keine Anlage Gipping, entferne Blockstern ting mit "location ~^/(assets)/"
  6. laufen: sudo -u git -H exec Rake Vermögen bündeln: precompile RAILS_ENV = Produktion

Urls:

  1. config/gitlab.yml Datei: host: example.com Hafen: 80
  2. config/unicorn.rb: hören "127.0.0.1:9095"
  3. ../gitlab-shell/config.yml: gitlab_url: http://www.example.com/gitlab

Gitlab geben git zwei Weise Zugang:

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

Ich bin nicht https verwenden.

Wenn Sie bekam:

Sie könnten config/gitlab.yml als host: example.com/gitlab konfigurieren. Entfernen Sie einfach die /gitlab.

nginx Konfigurationsdatei:

################################### 
##   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; 
} 

Apache (2.2.9) Konfigurationsdatei: Referenz gitlab.conf für Gitlab 6.0.6 und gitlab-8.0-apache2.2.conf für Gitlab 8.0.0 auf Apache 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> 
Verwandte Themen