หน้า 1 จากทั้งหมด 1

วิธี Setup SSL ให้กับ GitLab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้แล้วด้วย GitLab 12

โพสต์แล้ว: 08/09/2020 8:29 pm
โดย mindphp
วิธี Setup SSL ให้กับ Gitlab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้ GitLab 12.10.6
ตั้งแต่เวอร์ชั่นนี้ การเปิดใช้งาน SSL สามารถทำได้ง่ายๆ เพราะ Gitlab เค้ามี Options และ สามารถใช้งาน auto ของ Let's Encrypt สำหรับ renew ได้เองเลย
มาเริ่มกันเลย (ตัวอย่างนี้ ติดตั้ง Gitlab บน Ubuntu)
1. เปิดไฟล์ /etc/gitlab/gitlab.rb ขึ้นมาแก้ไข

โค้ด: เลือกทั้งหมด

nano /etc/gitlab/gitlab.rb
2. แก้ไข
external_url ให้ url ใช้ https ดังตัวอย่าง

โค้ด: เลือกทั้งหมด

external_url 'https://git.mindphp.com'
3. แก้ไข ส่วนของ Let's Encrypt integration ดังนี้

โค้ด: เลือกทั้งหมด

letsencrypt['enable'] = true
4. แก้ไข ส่วนของ GitLab NGINX

โค้ด: เลือกทั้งหมด

nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
5. เสร็จ แล้ว reconfigure ด้วยคำสั่ง

โค้ด: เลือกทั้งหมด

 sudo gitlab-ctl reconfigure
รอจนทำงานเสร็จ ระบบสร้าง และ gen cert ssl จาก letsencrypt ให้เรา

ถ้าเจอ Error ประมาณนี้
Running handlers:
There was an error running gitlab-ctl reconfigure:

letsencrypt_certificate[git.mindphp.com] (letsencrypt::http_authorization line 5) had an error: RuntimeError: acme_certificate[staging] (/opt/gitlab/embedded/c ookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 25) had an error: RuntimeError: ruby_block[create certificate for git.mindphp.com] (/opt/git lab/embedded/cookbooks/cache/cookbooks/acme/resources/certificate.rb line 108) had an error: RuntimeError: [git.mindphp.com] Validation failed, unable to reque st certificate
ให้แก้ปัญหาโดยการ

โค้ด: เลือกทั้งหมด

gitlab-ctl renew-le-certs
ระบบจะสร้างไฟล์ letsencrypt_certificate ไว้ให้ที่ /var/opt/gitlab/nginx/www/.well-known/acme-challenge/*
เท่านี้เราก็จะสามารถเข้าใช้งาน Gitlab ของเราได้ด้วย https แล้ว


ติดตามผลงานทางโปรแกรมตางๆ ของ Mindphp.com ได้ที่
https://git.mindphp.com
เรามี Open Source ไว้ให้ท่านนำไปใช้ และ รวมพัฒนากับเรามากมาย

Re: วิธี Setup SSL ให้กับ GitLab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้แล้วด้วย GitLab 12

โพสต์แล้ว: 08/09/2020 8:42 pm
โดย mindphp
ใช้ได้กับ gitlab ทุกเวอร์ชั่นที่สูงกว่านี้

ทำความสรู้จัก CI บน Gitlab

https://www.youtube.com/watch?v=edvobTl-tZo

Re: วิธี Setup SSL ให้กับ GitLab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้แล้วด้วย GitLab 12

โพสต์แล้ว: 06/10/2021 11:20 am
โดย mindphp
ตั้งให้ ระบบ auto_renew ssl ตามเวลาที่กำหนด

โค้ด: เลือกทั้งหมด

# Enable the auto renew feature
letsencrypt['auto_renew'] = true

# This example renews every 1 st day at 12:30
letsencrypt['auto_renew_hour'] = "12"
letsencrypt['auto_renew_minute'] = "30"
letsencrypt['auto_renew_day_of_month'] = "1"
renews ทุกๆ วันที่ 1 ของเดือน

Re: วิธี Setup SSL ให้กับ GitLab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้แล้วด้วย GitLab 12

โพสต์แล้ว: 02/02/2022 11:13 am
โดย mindphp
ถ้ามีการตั้ง renew อัตโนมัติแล้ว ระบบไม่ทำงาน
หรือ เจอ Error
gitlab-ctl renew-le-certs
Traceback (most recent call last):
7: from /opt/gitlab/embedded/bin/omnibus-ctl:23:in `<main>'
6: from /opt/gitlab/embedded/bin/omnibus-ctl:23:in `load'
5: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/omnibus-ctl-0.6.0/bin/omnibus-ctl:31:in `<top (required)>'
4: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/omnibus-ctl-0.6.0/lib/omnibus-ctl.rb:746:in `run'
3: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/omnibus-ctl-0.6.0/lib/omnibus-ctl.rb:204:in `block in add_command_under_category'
2: from /opt/gitlab/embedded/service/omnibus-ctl/letsencrypt.rb:21:in `block in load_file'
1: from /opt/gitlab/embedded/service/omnibus-ctl/lib/gitlab_ctl/util.rb:62:in `get_node_attributes'
/opt/gitlab/embedded/service/omnibus-ctl/lib/gitlab_ctl/util.rb:47:in `parse_json_file': Attributes not found in /opt/gitlab/embedded/nodes/ubuntu18-2vcpu-4gb-shop-git.json, has reconfigure been run yet? (GitlabCtl::Errors::NodeError)
สามารถแก้ไขได้ด้วยการ reconfigure ตามคำสั่งนี้

โค้ด: เลือกทั้งหมด

sudo gitlab-ctl reconfigure