วิธี Setup SSL ให้กับ GitLab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้แล้วด้วย GitLab 12
โพสต์แล้ว: 08/09/2020 8:29 pm
วิธี Setup SSL ให้กับ Gitlab เข้าใช้งาน https ได้ง่ายไม่ต้องแก้ไขโค้ดได้ GitLab 12.10.6
ตั้งแต่เวอร์ชั่นนี้ การเปิดใช้งาน SSL สามารถทำได้ง่ายๆ เพราะ Gitlab เค้ามี Options และ สามารถใช้งาน auto ของ Let's Encrypt สำหรับ renew ได้เองเลย
มาเริ่มกันเลย (ตัวอย่างนี้ ติดตั้ง Gitlab บน Ubuntu)
1. เปิดไฟล์ /etc/gitlab/gitlab.rb ขึ้นมาแก้ไข
2. แก้ไข
external_url ให้ url ใช้ https ดังตัวอย่าง
3. แก้ไข ส่วนของ Let's Encrypt integration ดังนี้
4. แก้ไข ส่วนของ GitLab NGINX
5. เสร็จ แล้ว reconfigure ด้วยคำสั่ง
รอจนทำงานเสร็จ ระบบสร้าง และ gen cert ssl จาก letsencrypt ให้เรา
ถ้าเจอ Error ประมาณนี้
ระบบจะสร้างไฟล์ letsencrypt_certificate ไว้ให้ที่ /var/opt/gitlab/nginx/www/.well-known/acme-challenge/*
เท่านี้เราก็จะสามารถเข้าใช้งาน Gitlab ของเราได้ด้วย https แล้ว
ติดตามผลงานทางโปรแกรมตางๆ ของ Mindphp.com ได้ที่
https://git.mindphp.com
เรามี Open Source ไว้ให้ท่านนำไปใช้ และ รวมพัฒนากับเรามากมาย
ตั้งแต่เวอร์ชั่นนี้ การเปิดใช้งาน SSL สามารถทำได้ง่ายๆ เพราะ Gitlab เค้ามี Options และ สามารถใช้งาน auto ของ Let's Encrypt สำหรับ renew ได้เองเลย
มาเริ่มกันเลย (ตัวอย่างนี้ ติดตั้ง Gitlab บน Ubuntu)
1. เปิดไฟล์ /etc/gitlab/gitlab.rb ขึ้นมาแก้ไข
โค้ด: เลือกทั้งหมด
nano /etc/gitlab/gitlab.rb
external_url ให้ url ใช้ https ดังตัวอย่าง
โค้ด: เลือกทั้งหมด
external_url 'https://git.mindphp.com'
โค้ด: เลือกทั้งหมด
letsencrypt['enable'] = true
โค้ด: เลือกทั้งหมด
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
โค้ด: เลือกทั้งหมด
sudo gitlab-ctl reconfigure
ถ้าเจอ 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
เท่านี้เราก็จะสามารถเข้าใช้งาน Gitlab ของเราได้ด้วย https แล้ว
ติดตามผลงานทางโปรแกรมตางๆ ของ Mindphp.com ได้ที่
https://git.mindphp.com
เรามี Open Source ไว้ให้ท่านนำไปใช้ และ รวมพัฒนากับเรามากมาย