首頁 >後端開發 >php教程 >gitlab 745 nginx apache 配置

gitlab 745 nginx apache 配置

WBOY
WBOY原創
2016-07-29 08:59:421318瀏覽

gitlab 7.4.5 參考 1, 2 從原始碼安裝。

本文 gitlab 7.4.5 運行環境 見 3。

nginx 設定參考原始碼自帶設定 lib/support/nginx/gitlab

<code><span>## GitLab</span><span>## Maintainer: @randx</span><span>##</span><span>## Lines starting with two hashes (##) are comments with information.</span><span>## Lines starting with one hash (#) are configuration parameters that can be uncommented.</span><span>##</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>####
##        CHUNKED TRANSFER      ##
###</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>#</span><span>##</span><span>## It is a known issue that Git-over-HTTP requires chunked transfer encoding [0]</span><span>## which is not supported by Nginx < 1.3.9 [1]. As a result, pushing a large object</span><span>## with Git (i.e. a single large file) can lead to a 411 error. In theory you can get</span><span>## around this by tweaking this configuration file and either:</span><span>## - installing an old version of Nginx with the chunkin module [2] compiled in, or</span><span>## - using a newer version of Nginx.</span><span>##</span><span>## At the time of writing we do not know if either of these theoretical solutions works.</span><span>## As a workaround users can use Git over SSH to push large files.</span><span>##</span><span>## [0] https://git.kernel.org/cgit/git/git.git/tree/Documentation/technical/http-protocol.txt#n99</span><span>## [1] https://github.com/agentzh/chunkin-nginx-module#status</span><span>## [2] https://github.com/agentzh/chunkin-nginx-module</span><span>##</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>#####
##         configuration         ##
###</span><span>######</span><span>######</span><span>######</span><span>######</span><span>######</span><span>##</span><span>##</span>upstream gitlab {
  server <span>unix</span>:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=<span>0</span>;
}

<span>## Normal HTTP host</span>
server {
  <span>#listen *:80 default_server;</span>
  listen *:<span>80</span> default_server;
  server_name mydomain.com; <span>## Replace this with something like gitlab.example.com</span>
  server_tokens <span>off</span>; <span>## Don't show the nginx version number, a security best practice</span>
  root /home/git/gitlab/public;

  <span>## Increase this if you want to upload large attachments</span><span>## Or if you want to accept large git objects over http</span>
  client_max_body_size <span>20</span>m;

  <span>## Individual nginx logs for this GitLab vhost</span>
  access_log  logs/mydomain.gitlab_access.log;
  error_log   logs/mydomain.gitlab_error.log;

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

  <span>## If a file, which is not found in the root folder is requested,</span><span>## then the proxy passes the request to the upsteam (gitlab unicorn).</span>
  location <span>@gitlab</span> {
    <span>## If you use HTTPS make sure you disable gzip compression</span><span>## to be safe against BREACH attack.</span><span># gzip off;</span><span>## https://github.com/gitlabhq/gitlabhq/issues/694</span><span>## Some requests take more than 30 seconds.</span>
    proxy_read_timeout      <span>300</span>;
    proxy_connect_timeout   <span>300</span>;
    proxy_redirect          <span>off</span>;

    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 <span>http</span>:<span>//gi</span>tlab;
  }

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

  error_page <span>502</span> /<span>502.</span>html;
}
</code>

Apache
apache(2.2.9) 設定參考 測試於 6.0.0 的 gitlab.conf,和測試於 8.0.0 的 gitlab-8.0-apache2.2.conf

<code><span>#######</span><span>#NameVirtualHost *:80</span><span>#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1</span><span>#Note this config assumes unicorn is listening on default port 8080.</span><span>#Module dependencies</span><span>#  mod_rewrite</span><span>#  mod_proxy</span><span>#  mod_proxy_http</span><span><VirtualHost *:80></span><span><span>ServerName</span></span> mydomain.com
  <span>ServerSignature</span><span>Off</span><span>ProxyPreserveHost</span><span>On</span><span># Ensure that encoded slashes are not decoded but left in their encoded state.</span><span># http://doc.gitlab.com/ce/api/projects.html#get-single-project</span><span>AllowEncodedSlashes</span> NoDecode

  <span><Location /></span><span><span>Order</span></span> deny,allow
    <span><span>Allow</span></span> from <span>all</span><span>ProxyPassReverse</span> http://127.0.0.1:9095
    <span>ProxyPassReverse</span> http://mydomain.com/
  <span></Location></span><span>#apache equivalent of nginx try files</span><span># http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files</span><span># http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab</span><span><span>RewriteEngine</span></span><span>on</span><span><span>RewriteCond</span></span><span>%{DOCUMENT_ROOT}</span>/<span>%{REQUEST_FILENAME}</span> !-f
  <span><span>RewriteRule</span></span> .* http://127.0.0.1:9095<span>%{REQUEST_URI}</span><span> [P,QSA,NE]</span><span># needed for downloading attachments</span><span><span>DocumentRoot</span></span> /home/git/gitlab/public

  <span>#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.</span><span><span>ErrorDocument</span></span> 404 /404.html
  <span><span>ErrorDocument</span></span> 422 /422.html
  <span><span>ErrorDocument</span></span> 500 /500.html
  <span><span>ErrorDocument</span></span> 503 /deploy.html

  <span>LogFormat</span><span>"%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b"</span> common_forwarded
  <span>ErrorLog</span>  logs/mydomain.gitlab_error.log
  <span>CustomLog</span> logs/mydomain.gitlab_forwarded.log common_forwarded
  <span>CustomLog</span> logs/mydomain.gitlab_access.log combined env=!dontlog
  <span>CustomLog</span> logs/mydomain.gitlab.log combined

<span></VirtualHost></span></code>

PS:
使用 relative url 的設定 請參閱 gitlab 7.4.5 relative url configuration

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介紹了gitlab 745 nginx apache 配置,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn