summaryrefslogtreecommitdiffstats
path: root/code/linux/gitserver.md
diff options
context:
space:
mode:
Diffstat (limited to 'code/linux/gitserver.md')
-rw-r--r--code/linux/gitserver.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/code/linux/gitserver.md b/code/linux/gitserver.md
index 53add30..b687fdc 100644
--- a/code/linux/gitserver.md
+++ b/code/linux/gitserver.md
@@ -135,7 +135,7 @@ echo "Success!"
135 135
136最初的设置是这样的: 136最初的设置是这样的:
137 137
138```conf 138```nginx
139server 139server
140{ 140{
141 # 这里用于将 http 请求重定向到 https,是一种常用的方式 141 # 这里用于将 http 请求重定向到 https,是一种常用的方式
@@ -183,7 +183,7 @@ fatal: unable to access 'https://git.player.com/test.git/': The requested URL re
183 183
184我们可以在仓库中执行 `git config http.receivepack true` 来开启 push 权限,但是这样的话,所有人都可以 push 代码了,这显然不是我们想要的。我们可以通过 `git config http.receivepack false` 来关闭 push 权限,这样的话,所有人都不能 push 代码了,这也不是我们想要的。那么,我们应该怎么做呢?更好的做法是这样的: 184我们可以在仓库中执行 `git config http.receivepack true` 来开启 push 权限,但是这样的话,所有人都可以 push 代码了,这显然不是我们想要的。我们可以通过 `git config http.receivepack false` 来关闭 push 权限,这样的话,所有人都不能 push 代码了,这也不是我们想要的。那么,我们应该怎么做呢?更好的做法是这样的:
185 185
186```conf 186```nginx
187$HTTP["querystring"] =~ "service=git-receive-pack" { 187$HTTP["querystring"] =~ "service=git-receive-pack" {
188 include "git-auth.conf" 188 include "git-auth.conf"
189} 189}
@@ -196,21 +196,21 @@ $HTTP["url"] =~ "^/git/.*/git-receive-pack$" {
196 196
197执行 git clone: 197执行 git clone:
198 198
199```log 199```plaintext
200[27/Nov/2018:22:18:00] "GET /test.git/info/refs?service=git-upload-pack HTTP/1.1" 200 363 "-" "git/1.9.1" 200[27/Nov/2018:22:18:00] "GET /test.git/info/refs?service=git-upload-pack HTTP/1.1" 200 363 "-" "git/1.9.1"
201[27/Nov/2018:22:18:00] "POST /test.git/git-upload-pack HTTP/1.1" 200 306 "-" "git/1.9.1" 201[27/Nov/2018:22:18:00] "POST /test.git/git-upload-pack HTTP/1.1" 200 306 "-" "git/1.9.1"
202``` 202```
203 203
204执行 git pull: 204执行 git pull:
205 205
206```log 206```plaintext
207[27/Nov/2018:22:20:25] "GET /test.git/info/refs?service=git-upload-pack HTTP/1.1" 200 363 "-" "git/1.9.1" 207[27/Nov/2018:22:20:25] "GET /test.git/info/refs?service=git-upload-pack HTTP/1.1" 200 363 "-" "git/1.9.1"
208[27/Nov/2018:22:20:25] "POST /test.git/git-upload-pack HTTP/1.1" 200 551 "-" "git/1.9.1" 208[27/Nov/2018:22:20:25] "POST /test.git/git-upload-pack HTTP/1.1" 200 551 "-" "git/1.9.1"
209``` 209```
210 210
211执行 git push: 211执行 git push:
212 212
213```log 213```plaintext
214[27/Nov/2018:22:19:33] "GET /test.git/info/refs?service=git-receive-pack HTTP/1.1" 401 204 "-" "git/1.9.1" 214[27/Nov/2018:22:19:33] "GET /test.git/info/refs?service=git-receive-pack HTTP/1.1" 401 204 "-" "git/1.9.1"
215admin [27/Nov/2018:22:19:33] "GET /test.git/info/refs?service=git-receive-pack HTTP/1.1" 200 193 "-" "git/1.9.1" 215admin [27/Nov/2018:22:19:33] "GET /test.git/info/refs?service=git-receive-pack HTTP/1.1" 200 193 "-" "git/1.9.1"
216admin [27/Nov/2018:22:19:33] "POST /test.git/git-receive-pack HTTP/1.1" 200 63 "-" "git/1.9.1" 216admin [27/Nov/2018:22:19:33] "POST /test.git/git-receive-pack HTTP/1.1" 200 63 "-" "git/1.9.1"
@@ -220,7 +220,7 @@ admin [27/Nov/2018:22:19:33] "POST /test.git/git-receive-pack HTTP/1.1" 200 63 "
220 220
221于是,我们对 nginx 的配置文件进行修改: 221于是,我们对 nginx 的配置文件进行修改:
222 222
223```conf 223```nginx
224server 224server
225{ 225{
226 listen 80; 226 listen 80;
@@ -452,7 +452,7 @@ sudo make install | tee install.log
452 452
453在`/etc/nginx/git-http-backend.conf`中写入以下内容,注意把域名、ssl 路径、htpasswd 认证文件换成自己的: 453在`/etc/nginx/git-http-backend.conf`中写入以下内容,注意把域名、ssl 路径、htpasswd 认证文件换成自己的:
454 454
455```conf 455```nginx
456# /etc/nginx/git-http-backend.conf 456# /etc/nginx/git-http-backend.conf
457fastcgi_pass unix:/var/run/fcgiwrap.socket; 457fastcgi_pass unix:/var/run/fcgiwrap.socket;
458include fastcgi_params; 458include fastcgi_params;
@@ -465,7 +465,7 @@ fastcgi_param REMOTE_USER $remote_user;
465 465
466而后,在`/etc/nginx/conf.d/cgit.conf`中写: 466而后,在`/etc/nginx/conf.d/cgit.conf`中写:
467 467
468```conf 468```nginx
469# /etc/nginx/conf.d/cgit.conf 469# /etc/nginx/conf.d/cgit.conf
470server { 470server {
471 listen 80; 471 listen 80;