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

แชร์ความรู้ Linux Ubuntu Web Server บทความ การ config server Linux FreeBSD Apache
การติดตั้ง XAMPP Mysql PHP ใครต้องการแชร์ความรู้เรื่องต่างๆ เหล่านี้ให้ ท่านหรืออื่น โพสที่หมวดนี้ได้

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

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

โพสต์ที่ยังไม่ได้อ่าน โดย 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 ไว้ให้ท่านนำไปใช้ และ รวมพัฒนากับเรามากมาย
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

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

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ใช้ได้กับ gitlab ทุกเวอร์ชั่นที่สูงกว่านี้

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

https://www.youtube.com/watch?v=edvobTl-tZo
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

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

โพสต์ที่ยังไม่ได้อ่าน โดย 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 ของเดือน
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

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

โพสต์ที่ยังไม่ได้อ่าน โดย 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
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 69