Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GitLab behind nginx enabled basic_auth?

I've successfully installed GitLab for management of private repositories (it's quite awesome!).

The problem I am having is by default, Gitlab login is presented when anyone hits my subdomain. I would like to protect the entire area with a basic_auth layer before the user gets the GitLab login screen. Unfortunately, this breaks my ability to push/pull from GitLab when it's enabled.

my nginx config to enable basic_auth:

  auth_basic            "Restricted";
  auth_basic_user_file  htpasswd;

Any ideas on how I can enable basic_auth without breaking git / gitlab functionality?

like image 471
JG707 Avatar asked Apr 15 '13 19:04

JG707


People also ask

Does GitLab use nginx?

By default, Omnibus GitLab installs GitLab with bundled NGINX. Omnibus GitLab allows webserver access through the gitlab-www user, which resides in the group with the same name. To allow an external webserver access to GitLab, the external webserver user needs to be added to the gitlab-www group.

What is Auth_basic in nginx?

auth_basic. auth_basic_user_file. The ngx_http_auth_basic_module module allows limiting access to resources by validating the user name and password using the “HTTP Basic Authentication” protocol. Access can also be limited by address, by the result of subrequest, or by JWT.


1 Answers

Add this to /etc/gitlab/gitlab.rb:

nginx['custom_gitlab_server_config'] = "auth_basic 'Restricted';\n  auth_basic_user_file htpasswd;\n"

And run gitlab-ctl reconfigure

like image 164
Nicolas BADIA Avatar answered Sep 29 '22 07:09

Nicolas BADIA