Maison > développement back-end > tutoriel php > gitlab 745 nginx apache 配置

gitlab 745 nginx apache 配置

WBOY
Libérer: 2016-07-29 08:59:42
original
1324 Les gens l'ont consulté

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 <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;
}
</span></code>
Copier après la connexion

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></virtualhost></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></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></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></span></code>
Copier après la connexion

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教程有兴趣的朋友有所帮助。

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal