diff options
Diffstat (limited to 'code/linux/gitserver.md')
-rw-r--r-- | code/linux/gitserver.md | 16 |
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 |
139 | server | 139 | server |
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" |
215 | admin [27/Nov/2018:22:19:33] "GET /test.git/info/refs?service=git-receive-pack HTTP/1.1" 200 193 "-" "git/1.9.1" | 215 | admin [27/Nov/2018:22:19:33] "GET /test.git/info/refs?service=git-receive-pack HTTP/1.1" 200 193 "-" "git/1.9.1" |
216 | admin [27/Nov/2018:22:19:33] "POST /test.git/git-receive-pack HTTP/1.1" 200 63 "-" "git/1.9.1" | 216 | admin [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 |
224 | server | 224 | server |
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 |
457 | fastcgi_pass unix:/var/run/fcgiwrap.socket; | 457 | fastcgi_pass unix:/var/run/fcgiwrap.socket; |
458 | include fastcgi_params; | 458 | include 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 |
470 | server { | 470 | server { |
471 | listen 80; | 471 | listen 80; |