gitlab 745 nginx apache 配置
程序员文章站
2022-06-06 19:50:03
...
gitlab 7.4.5 参照 1, 2 从源码安装。
本文 gitlab 7.4.5 运行环境 见 3。
nginx 配置参照源码自带配置 lib/support/nginx/gitlab
## GitLab## Maintainer: @randx#### Lines starting with two hashes (##) are comments with information.## Lines starting with one hash (#) are configuration parameters that can be uncommented.####################################
## CHUNKED TRANSFER ##
###################################### It is a known issue that Git-over-HTTP requires chunked transfer encoding [0]## which is not supported by Nginx ## with Git (i.e. a single large file) can lead to a 411 error. In theory you can get## around this by tweaking this configuration file and either:## - installing an old version of Nginx with the chunkin module [2] compiled in, or## - using a newer version of Nginx.#### At the time of writing we do not know if either of these theoretical solutions works.## As a workaround users can use Git over SSH to push large files.#### [0] https://git.kernel.org/cgit/git/git.git/tree/Documentation/technical/http-protocol.txt#n99## [1] https://github.com/agentzh/chunkin-nginx-module#status## [2] https://github.com/agentzh/chunkin-nginx-module#####################################
## 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 mydomain.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;
## 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/mydomain.gitlab_access.log;
error_log logs/mydomain.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 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
apache(2.2.9) 配置参照 测试于 6.0.0 的 gitlab.conf,和测试于 8.0.0 的 gitlab-8.0-apache2.2.conf
########NameVirtualHost *:80#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1#Note this config assumes unicorn is listening on default port 8080.#Module dependencies# mod_rewrite# mod_proxy# mod_proxy_http ServerName mydomain.com
ServerSignatureOffProxyPreserveHostOn# Ensure that encoded slashes are not decoded but left in their encoded state.# http://doc.gitlab.com/ce/api/projects.html#get-single-projectAllowEncodedSlashes NoDecode
Order deny,allow
Allow from allProxyPassReverse http://127.0.0.1:9095
ProxyPassReverse http://mydomain.com/
#apache equivalent of nginx try files# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files# http://*.com/questions/10954516/apache2-proxypass-for-rails-app-gitlabRewriteEngineonRewriteCond%{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:9095%{REQUEST_URI} [P,QSA,NE]# needed for downloading attachmentsDocumentRoot /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/mydomain.gitlab_error.log
CustomLog logs/mydomain.gitlab_forwarded.log common_forwarded
CustomLog logs/mydomain.gitlab_access.log combined env=!dontlog
CustomLog logs/mydomain.gitlab.log combined
PS:
使用 relative url 的配置 见 gitlab 7.4.5 relative url configuration
以上就介绍了gitlab 745 nginx apache 配置,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
推荐阅读
-
Nginx配合Apache或Tomcat的动静分离基本配置实例
-
lanmp(Linux Apache Nginx Mysql Php) 的安装配置
-
详解Nginx与Apache共用80端口的配置方法
-
Apache、Nginx 服务配置服务器端包含(SSI)
-
Mac下安装与配置nginx php7.1,apache和nginx解析PHP的原理
-
apache2, nginx, iis反向代理简单配置
-
Nginx、Apache、Lighttpd禁止目录执行php配置示例
-
lanmp(Linux Apache Nginx Mysql Php) 的安装配置
-
配置Nginx+PHP的正确思路与过程 nginx apache nginx php nginx rewrite
-
修改PHP配置文件上传大文件几种方法(apache/nginx)