Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added nginx config example to cut-off ".git" #173

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions web-server/nginx/gitlab-ssl-limit-cutgit
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# GITLAB with SSL with connection limit with requests limit with ".git" cut-off

limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

server {
listen 0.0.0.0:443 ssl;
root /home/git/gitlab/public;

ssl on;
ssl_certificate /etc/nginx/gitlab.crt;
ssl_certificate_key /etc/nginx/gitlab.key;
ssl_protocols SSLv3 TLSv1 TLSv1.2;
ssl_ciphers AES:HIGH:!ADH:!MD5;
ssl_prefer_server_ciphers on;
server_name git.example.com;

location ~ ^/([^/]*/[^/]*)\.git {
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location ~ ^/([^/]+/[^/]+)/(.*) {
rewrite ^/([^/]+/[^/]+)/info/(.*) /$1.git/info/$2 last;
rewrite ^/([^/]+/[^/]+)/git-(.*) /$1.git/git-$2 last;
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location ~ /$ {
limit_req zone=one burst=15 nodelay;
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location / {
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location @gitlab {
limit_conn conn_limit_per_ip 20;
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer $scheme://$host$request_uri;
client_max_body_size 256M;
proxy_redirect off;

proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;

proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl on;
}
}

server {
listen *:80 default;
location / {
rewrite ^ https://git.example.com$request_uri? permanent;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document somewhere that people have to change this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my English skills, but I don't understand the question.

Did you mean "why people have to change that"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point you have hardcoded the url https://git.example.com people may not know that they have to change this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Can you show an example of the "documentation"? Should I just add a note in the first lines of this configuration file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axilleas Yeah thanks :)

}
}

70 changes: 70 additions & 0 deletions web-server/nginx/gitlab-ssl-limit-cutgit-anotherstartpage
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# GITLAB with SSL with connection limit with requests limit with ".git" cut-off
# and with "public/projects" as the start page

limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

server {
listen 0.0.0.0:443 ssl;
root /home/git/gitlab/public;

ssl on;
ssl_certificate /etc/nginx/gitlab.crt;
ssl_certificate_key /etc/nginx/gitlab.key;
ssl_protocols SSLv3 TLSv1 TLSv1.2;
ssl_ciphers AES:HIGH:!ADH:!MD5;
ssl_prefer_server_ciphers on;
server_name git.example.com;

location = /users/sign_in {
if ($http_referer ~ "^$") {
rewrite ^ https://git.example.com/public/projects redirect;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document somewhere that people have to change this?

}
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location ~ ^/([^/]*/[^/]*)\.git {
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location ~ ^/([^/]+/[^/]+)/(.*) {
rewrite ^/([^/]+/[^/]+)/info/(.*) /$1.git/info/$2 last;
rewrite ^/([^/]+/[^/]+)/git-(.*) /$1.git/git-$2 last;
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location ~ /$ {
limit_req zone=one burst=15 nodelay;
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location / {
try_files maintenance.html $uri $uri/index.html $uri.htm @gitlab;
}

location @gitlab {
limit_conn conn_limit_per_ip 20;
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Referer $scheme://$host$request_uri;
client_max_body_size 256M;
proxy_redirect off;

proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
proxy_redirect off;

proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl on;
}
}

server {
listen *:80 default;
location / {
rewrite ^ https://git.example.com$request_uri? permanent;
}
}