Skip to content

Commit f987ce0

Browse files
committed
feat: allow read without authentication
1 parent 8f5f1a1 commit f987ce0

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# gitbox with gitlist v.0.5.0
1+
# gitbox with gitlist v.1.0.1
22
# https://github.com/nmarus/docker-gitbox
33
# Nicholas Marus <[email protected]>
44

@@ -38,14 +38,15 @@ RUN sed -i 's/FCGI_USER="www-data"/FCGI_USER="git"/g' /etc/init.d/fcgiwrap && \
3838

3939
# Install gitlist
4040
RUN mkdir -p /var/www && \
41-
wget -q -O /var/www/gitlist-0.5.0.tar.gz https://s3.amazonaws.com/gitlist/gitlist-0.5.0.tar.gz && \
42-
tar -zxvf /var/www/gitlist-0.5.0.tar.gz -C /var/www && \
41+
wget -q -O /var/www/gitlist-v1.0.1.tar.gz https://github.com/klaussilveira/gitlist/releases/download/v1.0.1/gitlist-v1.0.1.tar.gz && \
42+
tar -zxvf /var/www/gitlist-v1.0.1.tar.gz -C /var/www && \
4343
chmod -R 777 /var/www/gitlist && \
4444
mkdir -p /var/www/gitlist/cache && \
4545
chmod 777 /var/www/gitlist/cache
4646

4747
# Create config files for container startup and nginx
4848
COPY nginx.conf /etc/nginx/nginx.conf
49+
COPY git-http-backend.conf /etc/nginx/git-http-backend.conf
4950

5051
# Create config files for container
5152
COPY config.ini /var/www/gitlist/config.ini

git-http-backend.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
client_max_body_size 0;
2+
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
3+
fastcgi_param GIT_HTTP_EXPORT_ALL "";
4+
fastcgi_param GIT_PROJECT_ROOT /repos;
5+
fastcgi_param PATH_INFO $1;
6+
fastcgi_param REMOTE_USER $remote_user;
7+
include /etc/nginx/fastcgi_params;
8+
fastcgi_pass unix:/var/run/fcgiwrap.socket;

nginx.conf

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ events {
77
}
88

99
http {
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

Comments
 (0)