nginx容器+git不再工作了
我的服务器上有一个nginx容器作为反向代理。我将服务器用于git。我将nginx conf文件拆分为多个文件,并将所有文件都包含在default.conf-file中。然后我重新构建了nginx容器并启动了它。在此之后,我无法提取存储库 git存储库位于服务器上的以下路径下: /mnt/bigdata/git/ 此路径也存在于nginx容器中,并安装到服务器上 我的nginx conf如下所示:nginx容器+git不再工作了,git,docker,nginx,Git,Docker,Nginx,我的服务器上有一个nginx容器作为反向代理。我将服务器用于git。我将nginx conf文件拆分为多个文件,并将所有文件都包含在default.conf-file中。然后我重新构建了nginx容器并启动了它。在此之后,我无法提取存储库 git存储库位于服务器上的以下路径下: /mnt/bigdata/git/ 此路径也存在于nginx容器中,并安装到服务器上 我的nginx conf如下所示: server { listen 443 ssl http2 default_server;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name mySite.de;
include snippets/ssl-mySite.de;
include snippets/ssl-params.conf;
location /git(/.*) {
root /mnt/bigdata/git;
client_max_body_size 0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this.
auth_basic "Git Login"; # Whatever text will do.
auth_basic_user_file "/mnt/bigdata/git/htpasswd";
include /etc/nginx/fastcgi_params; # Include the default fastcgi configs
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; # Tells fastcgi to pass the request to the git http backend executable
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /mnt/bigdata/git; # /mnt/bigdata/git is the location of all of your git repositories.
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $1; # Takes the capture group from our location directive and gives git that.
fastcgi_pass unix:/var/run/fcgiwrap.socket; # Pass the request to fastcgi
}
}
我的nginx日志中出现以下错误:
2018/03/03 20:44:16 [error] 20#20: *1 open() "/etc/nginx/html/git/Testing.git/info/refs" failed (2: No such file or directory), client: 135.21.244.72, server: mySite.de, request: "GET /git/Testing.git/info/refs?service=git-upload-pack HTTP/1.1", host: "mySite.de"
135.21.244.72 - - [03/Mar/2018:20:44:16 +0000] "GET /git/Testing.git/info/refs?service=git-upload-pack HTTP/1.1" 404 169 "-" "git/2.7.4" "-"
所以nginx试图打开/etc/nginx/html/git。似乎root命令没有任何效果。我将nginx conf更改为以下内容:
...
root /mnt/bigdata/git;
location /git(/.*) {
client_max_body_size 0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this.
...
nginx错误:
2018/03/03 20:49:33 [error] 20#20: *1 open() "/mnt/bigdata/git/git/Testing.git/info/refs" failed (2: No such file or directory), client: 135.21.244.72, server: mySite.de, request: "GET /git/Testing.git/info/refs?service=git-upload-pack HTTP/1.1", host: "mySite.de"
135.21.244.72 - - [03/Mar/2018:20:49:33 +0000] "GET /git/Testing.git/info/refs?service=git-upload-pack HTTP/1.1" 404 169 "-" "git/2.7.4" "-"
好的/mnt/bigdata/git/git。。。不存在,因此我必须删除/git标记并将其更改为:
...
root /mnt/bigdata;
location /git(/.*) {
client_max_body_size 0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this.
...
nginx日志:
135.21.244.72 - - [03/Mar/2018:20:51:53 +0000] "GET /git/Testing.git/info/refs?service=git-upload-pack HTTP/1.1" 200 0 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:51:53 +0000] "GET /git/Testing.git/HEAD HTTP/1.1" 200 23 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:54:37 +0000] "GET /git/Testing.git/info/refs?service=git-receive-pack HTTP/1.1" 200 0 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:54:37 +0000] "GET /git/Testing.git/HEAD HTTP/1.1" 200 23 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:54:37 +0000] "PROPFIND /git/Testing.git/ HTTP/1.1" 405 173 "-" "git/2.7.4" "-"
这次我可以将存储库克隆到我的计算机上。但存储库是空的:
warning: You appear to have cloned an empty repository.
那不是真的。如果我查看服务器上的Testing.git文件夹,我可以看到多个包。现在,我在空文件夹中添加了一个文件,并尝试将其推送到服务器。我在终端上发现以下错误:
error: Cannot access URL https://mySite.de/git/Testing.git/, return code 22
fatal: git-http-push failed
error: failed to push some refs to 'https://mySite.de/git/Testing.git'
nginx日志:
135.21.244.72 - - [03/Mar/2018:20:51:53 +0000] "GET /git/Testing.git/info/refs?service=git-upload-pack HTTP/1.1" 200 0 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:51:53 +0000] "GET /git/Testing.git/HEAD HTTP/1.1" 200 23 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:54:37 +0000] "GET /git/Testing.git/info/refs?service=git-receive-pack HTTP/1.1" 200 0 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:54:37 +0000] "GET /git/Testing.git/HEAD HTTP/1.1" 200 23 "-" "git/2.7.4" "-"
135.21.244.72 - - [03/Mar/2018:20:54:37 +0000] "PROPFIND /git/Testing.git/ HTTP/1.1" 405 173 "-" "git/2.7.4" "-"
nginx dockerfile:
FROM nginx:1.13
RUN mkdir /etc/nginx/snippets
RUN mkdir -p /etc/nginx/conf-files
RUN mkdir -p /etc/ssl/certs/
RUN mkdir -p /etc/letsencrypt/live/mySite.de/
RUN mkdir -p /mnt/bigdata/git
VOLUME [ "/etc/nginx/conf-files", "/etc/letsencrypt/live/mySite.de/","/etc/ssl/certs/","/etc/conf.d/","/etc/nginx/snippets/","/mnt/bigdata/git" ]
COPY start-nginx.sh .
RUN apt-get clean && apt-get update && apt-get install -y nano spawn-fcgi fcgiwrap wget curl apache2-utils git
RUN sed -i 's/www-data/nginx/g' /etc/init.d/fcgiwrap
RUN chown nginx:nginx /etc/init.d/fcgiwrap
RUN mkdir /scripts
ADD scripts/ /scripts
EXPOSE 80
EXPOSE 443
CMD /etc/init.d/fcgiwrap start \
&& nginx -g 'daemon off;'
将conf文件从nginx更改回我的旧文件修复了这个问题。但是我需要将nginx conf与includes一起使用
我的旧nginx配置:
我的新nginx配置不工作:
/etc/nginx/conf files/jira-confluence-upstream.conf:
/etc/nginx/conf文件/chestration-upstream.conf:
/etc/nginx/conf文件/corchestra-ports.conf:
/etc/nginx/conf files/jira-confluence-location.conf:
/etc/nginx/conf文件/corchestra-location.conf:
我只需进入服务器上的git存储库并运行:
sudo git update-server-info
改变
location /git(/.*) {
到
server {
listen 8443;
listen 8444;
listen 8019;
location / {
proxy_pass http://docker-orchestra-port:$server_port;
}
}
location /jira {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://docker-jira/jira;
client_max_body_size 100M;
add_header X-Frame-Options ALLOW;
}
location /confluence {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://docker-conf/confluence;
proxy_redirect http://docker-conf/confluence https://MySite.de;
client_max_body_size 100M;
add_header X-Frame-Options SAMEORIGIN;
}
location /synchrony {
proxy_set_header X-Forwarded-Host $host;
location /orchestra {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://docker-orchestra/orchestra;
proxy_redirect http://docker-orchestra/orchestra https://MySite.de/orchestra;
client_max_body_size 100M;
add_header X-Frame-Options SAMEORIGIN;
}
sudo git update-server-info
location /git(/.*) {
location ~ /git(/.*) {