77}
88
99http {
10-
1110 sendfile on;
1211 tcp_nopush on;
1312 tcp_nodelay on;
@@ -32,19 +31,32 @@ http {
3231 root /var/www/gitlist;
3332 index index .php;
3433
35- auth_basic "Restricted" ;
36- auth_basic_user_file /ng-auth/htpasswd;
37-
38- #git SMART HTTP
39- location ~ /git( /.*\.git.*) {
40- client_max_body_size 0;
41- fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http -backend;
42- fastcgi_param GIT_HTTP_EXPORT_ALL "" ;
43- fastcgi_param GIT_PROJECT_ROOT /repos;
44- fastcgi_param PATH_INFO $1 ;
45- fastcgi_param REMOTE_USER $remote_user ;
46- include /etc/nginx/fastcgi_params;
47- fastcgi_pass unix:/var/run/fcgiwrap.socket;
34+ location ~ /git( /.*) {
35+ if ( $arg_service = git-receive-pack) {
36+ rewrite /git( /.*) /git_write$1 last;
37+ }
38+
39+ if ( $uri ~ ^/git/.*/git-receive-pack$) {
40+ rewrite /git( /.*) /git_write$1 last;
41+ }
42+
43+ if ( $arg_service = git-upload-pack) {
44+ rewrite /git( /.*) /git_read$1 last;
45+ }
46+
47+ if ( $uri ~ ^/git/.*/git-upload-pack$) {
48+ rewrite /git( /.*) /git_read$1 last;
49+ }
50+ }
51+
52+ location ~ /git_read( /.*) {
53+ include git-http -backend.conf;
54+ }
55+
56+ location ~ /git_write( /.*) {
57+ auth_basic "Pushing to Git repositories is restricted" ;
58+ auth_basic_user_file /ng-auth/htpasswd;
59+ include git-http -backend.conf;
4860 }
4961
5062 #robots
0 commit comments