Category: Hosting

Errbit + HTTPS: Setting up Errbit reporter (Airbrake v5 gem) to work with self-signed HTTPS certificate

Note: If you're using old Errbit version (0.2.0, 0.4.0) and an old Airbrake version (v4) please refer to this manual to make it work with self-signed certificates.

Having an error catcher like Errbit behind SSL is generally a good idea. Especially when Errbit is hosted on a different server than you application (for example when you manage multiple apps with one Errbit instance). In many cases you will have a self-signed certificate (why would you pay for a cert for internal tool). If you try to use it with Airbrake, you will see following error:

Airbrake:
  HTTP error: SSL_connect returned=1 errno=0 state=unknown state: certificate verify failed

Unfortunately, global SSL certificates verification disabling hack (solution that used to work with Airbrake notifier v4) won't work:

# No longer working!
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

Luckily, Airbrake notifier is written pretty well, so hacking it (and disabling per request SSL certificate verification) is not hard at all. Here's a full code you need to place in config/initializers/errbit.rb to make it work:

module Patches
  module Airbrake
    module SyncSender
      def build_https(uri)
        super.tap do |req|
          req.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
      end
    end
  end
end

Airbrake::SyncSender.prepend(::Patches::Airbrake::SyncSender)

After that (and configuring Airbrake notifier), you can test it out like this:

Airbrake.notify :test

Synology DMS 6 + Gitlab Docker + Gmail

When you'll setup your Gitlab instance using Synology DMS 6.0 UI, despite the fact that you've provided all the Gmail credentials, you will notice that it does not send any emails. You probably end up with a message similar to this one when:

EOFError: end of file reached

It may sound a bit enigmatic, but in general it means that your Gmail setup is wrong. Unfortunately you cannot change it using the UI. Fixing this requires a SSH connection.

Warning: I’m not responsible for any damages or injury, including but not limited to special or consequential damages, that result from your use of this instruction.

Stop your Gitlab using DMS UI

First, you need to stop your Gitlab instance via DMS UI:

  1. So to Package Manager
  2. Select Gitlab
  3. Select "Actions"
  4. Click on the "Stop" button

gitlab

Change your synology_gitlab.config via SSH

This one is a bit harder. Here are the th ings you need to know before you start:

  • How to log in via SSH into admin account
  • How to install (if you don't have) vim (or any other console text editor)
  • How to navigate in a Linux shell

So, if you know this things, you are ready to go!

  1. Log in into your Synology server via SSH as admin user
  2. Become a root (sudo su + password)
  3. Go to /usr/syno/etc/packages/Docker (cd /usr/syno/etc/packages/Docker)
  4. Edit synology_gitlab.config (vim synology_gitlab.config)
  5. Replace or add given config options into the env_variables section
  6. Save the file

Those are the options you need to set:

{
  "key":"SMTP_ENABLED",
  "value":"true"
},
{
  "key":"SMTP_DOMAIN",
  "value":"www.gmail.com"
},
{
  "key":"SMTP_HOST",
  "value":"smtp.gmail.com"
},
{
  "key":"SMTP_PORT",
  "value":"587"
},
{
  "key":"SMTP_USER",
  "value":"your user name"
},
{
  "key":"SMTP_PASS",
  "value":"your password"
},
{
  "key":"SMTP_OPENSSL_VERIFY_MODE",
  "value":"none"
},
{
  "key":"SMTP_AUTHENTICATION",
  "value":"login"
},
{
  "key":"SMTP_STARTTLS",
  "value":"true"
}

The whole file should look more or less like that:

{
  "cap_add":[

  ],
  "cap_drop":[

  ],
  "cmd":"",
  "cpu_priority":0,
  "ddsm_bind_share":"",
  "devices":[

  ],
  "enable_publish_all_ports":false,
  "enabled":true,
  "env_variables":[
    {
      "key":"GITLAB_HOST",
      "value":"gitdomain"
    },
    {
      "key":"GITLAB_PORT",
      "value":"port"
    },
    {
      "key":"GITLAB_SSH_PORT",
      "value":"port"
    },
    {
      "key":"GITLAB_EMAIL",
      "value":"email"
    },
    {
      "key":"DB_TYPE",
      "value":"mysql"
    },
    {
      "key":"DB_HOST",
      "value":"172.17.0.1"
    },
    {
      "key":"DB_NAME",
      "value":"gitlab"
    },
    {
      "key":"DB_USER",
      "value":"gitlab"
    },
    {
      "key":"DB_PASS",
      "value":"password"
    },
    {
      "key":"GITLAB_SECRETS_DB_KEY_BASE",
      "value":"secret"
    },
    {
      "key":"SMTP_ENABLED",
      "value":"true"
    },
    {
      "key":"SMTP_DOMAIN",
      "value":"www.gmail.com"
    },
    {
      "key":"SMTP_HOST",
      "value":"smtp.gmail.com"
    },
    {
      "key":"SMTP_PORT",
      "value":"587"
    },
    {
      "key":"SMTP_USER",
      "value":"email"
    },
    {
      "key":"SMTP_PASS",
      "value":"password"
    },
    {
      "key":"SMTP_OPENSSL_VERIFY_MODE",
      "value":"none"
    },
    {
      "key":"SMTP_AUTHENTICATION",
      "value":"login"
    },
    {
      "key":"SMTP_STARTTLS",
      "value":"true"
    }
  ],
  "exporting":false,
  "id":"id",
  "image":"sameersbn/gitlab:8.6.2",
  "is_ddsm":false,
  "is_package":true,
  "links":[
    {
      "alias":"redisio",
      "link_container":"synology_gitlab_redis"
    }
  ],
  "memory_limit":0,
  "name":"synology_gitlab",
  "pin":false,
  "port_bindings":[
    {
      "container_port":80,
      "host_port": port,
      "type":"tcp"
    },
    {
      "container_port":22,
      "host_port": port,
      "type":"tcp"
    }
  ],
  "privileged":false,
  "shortcut":{
    "enable_shortcut":false,
    "enable_status_page":false,
    "enable_web_page":false,
    "web_page_url":""
  },
  "volume_bindings":[
    {
      "host_volume_file":"/docker/gitlab",
      "mount_point":"/home/git/data",
      "type":"rw"
    }
  ]
}

Start your Gitlab using DMS UI

Procedure is exactly the same as stopping except the last step: just click on "Run" button instead of "Stop".

Retry all failed tasks in the Gitlab Sidekiq panel

  1. Log in to your Gitlab admin account
  2. Go to the "Admin area" (right top corner icon) - /admin
  3. Click on "Background jobs" (left bottom corner) - /admin/background_jobs
  4. Go to "Retries"
  5. If you have any, click on "Retry all" to reexecute all the failed tasks

sidekiq

And that's all! If you didn't make any mistakes, your Gitlab emails should be sent via provided Gmail account.

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑