Score:0

How can I configure gitlab and nginx as a reverse proxy with SSL authenticating to Azure AD?

gb flag

I've been pushing on this for days, I'm really hoping some kind soul can help.

Nginx is sitting on an Ubuntu machine in Azure. On that same machine, Docker engine is running a Gitlab container (which uses nginx for serving it up.)

I've gotten as far as getting everything working the way I want, except just over plain http. Yesterday I added SSL, which was not successful, and now I'm having trouble even getting back to easy old port 80.

For the reverse proxy, I have 2 config files for nginx, one for http, and one for https:

server {
        listen 80;
        server_name gitlab.mydomain.com;
        location / {
                proxy_pass http://localhost:5080;
        }
}

The last thing I added was the proxy_redirect in the SSL config because my browser was trying to redirect to my local localhost:

server {
  listen 443 ssl;
  server_name gitlab.mydomain.com;
  ssl_certificate /srv/gitlab/cert/cert.pem;
  ssl_certificate_key /srv/gitlab/cert/key.pem;
  location / {
    proxy_pass http://localhost:5443;
    proxy_redirect http://localhost:5080/ https://gitlab.mydomain.com/;
  }
}

Here is the yaml for gitlab:

services:
  web:
    image: 'gitlab/gitlab-ee:latest'
    container_name: gitlab
    restart: always
    hostname: gitlab
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab.mydomain.com'
        letsencrypt['enable'] = false
        #nginx['listen_port'] = 443
        #nginx['listen_https'] = true
        #nginx['ssl_certificate'] = "/etc/gitlab/cert/cert.pem"
        #nginx['ssl_certificate_key'] = "/etc/gitlab/cert/key.pem"
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
        gitlab_rails['omniauth_enabled'] = true
        gitlab_rails['omniauth_allow_single_sign_on'] = ['openid_connect']
        gitlab_rails['omniauth_auto_link_ldap_user'] = false
        gitlab_rails['omniauth_block_auto_created_users'] = false
        gitlab_rails['omniauth_sync_email_from_provider'] = ['openid_connect']
        gitlab_rails['omniauth_auto_sign_in_with_provider'] = ['openid_connect']
        gitlab_rails['omniauth_providers'] = [
          {
            name: "openid_connect",
            label: "label",

            args: {
              name: "openid_connect",
              scope: ["openid", "profile", "email"],
              response_type: "code",
              issuer:  "https://login.microsoftonline.com/secret/v2.0",
              client_auth_method: "query",
              discovery: true,
              uid_field: "preferred_username",
              pkce: true,
              client_options: {
                identifier: "secret",
                secret: "secret",
                redirect_uri: "https://gitlab.mydomain.com/users/auth/openid_connect/callback"
              }
            }
          }
        ]
    ports:
      - '5080:80'
      #- '5443:443'
      - '5022:22'
    volumes:
      - '/srv/gitlab/cert:/etc/gitlab/cert'
      - '/srv/gitlab/config:/etc/gitlab'
      - '/srv/gitlab/logs:/var/log/gitlab'
      - '/srv/gitlab/data:/var/opt/gitlab'
    shm_size: '256m'

As you can see, I've been experimenting with adding and removing https on the gitlab config. You may also intuit that I'm trying to configure oauth to Azure, hence the need for SSL. I had it working to the point where I could actually authenticate to Azure and then it was sad about the non-secure connection. Once I tried to turn on SSL, I can't even hit gitlab over the internet anymore.

I really appreciate any help! I am open to configuration changes, but obviously there's a reason I'm doing it this way, so simply removing nginx or something is not quite what I'm going for.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.