Hướng dẫn trỏ Domain với Redmine và cấu hình SSL với Let’s Enscrypt

Tác giả: 24/08/2022

Chuẩn bị

Sau khi đăng ký sử dụng Template Redmine trên hệ thống Cloud365 của Nhân Hòa, quý khách sẽ nhận được thông tin quản trị:

  • Redmine server chạy trên địa chỉ IP 192.168.100.100
  • Tên miền redmine.workfromhome.vn đã được trỏ về địa chỉ IP 192.168.100.100

Đảm bảo tên miền đã được trỏ đúng về địa chỉ IP bằng cách truy cập trang web: https://dnschecker.org/ để kiểm tra

Lưu ý: redmine.workfromhome.vn và IP 192.168.100.100 là domain và IP ví dụ trong bài viết này. Bạn chú ý sử dụng domain và IP đúng của mình.

Cấu hình Redmine với domain redmine.cloud365.vn

Truy cập vào server với thông tin quản trị server (Thông tin remote desktop/ssh quản trị server).

Sử dụng phần mềm MobaXterm và thực hiện truy cập:

ssh root@192.168.100.100

Chỉnh sửa nhanh file cấu hình cho virtual host redmine (Lưu ý domain phù hợp của bạn)

sed -i 's|DocumentRoot /var/www/redmine/public|\tServerName redmine.workfromhome.vn \n \tDocumentRoot /var/www/redmine/public|g' /etc/httpd/conf.d/redmine.conf

Kiểm tra lại

cat /etc/httpd/conf.d/redmine.conf

Restart lại dịch vụ Apache

systemctl restart httpd

Sử dụng trình duyệt và truy cập vào địa chỉ http://redmine.workfromhome.vn

Cài đặt SSL Let’s Enscrypt cho Redmine

Lưu ý bước này chỉ có thể thực hiện khi bạn đã trỏ được domain cho Redmine.

Các bạn có thể tham khảo thêm về Let’s enscrypt tại đây:

Cài đặt certbot

yum install epel-release -y
yum install certbot python2-certbot-apache mod_ssl -y
Tạo chứng chỉ SSL free với certbot:
certbot --apache -d redmine.workfromhome.vn

Khai báo các thông tin cần thiết với certbot

  • Địa chỉ email: Địa chỉ email của bạn để nhận các thông báo
  • Đồng ý với điều khoản sử dụng: A
  • Public thông tin về Email: N
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): huytm@rd.nhanhoa.com
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N

Chọn cách thức hoạt động của sau khi cài đặt SSL

  • Sử dụng song song cả http và https cho trang web
  • Chuyển hướng toàn bộ các request sang https

→ Chọn 2

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting vhost in /etc/httpd/conf.d/redmine.conf to ssl vhost in /etc/httpd/conf.d/redmine-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://redmine.workfromhome.vn
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=redmine.workfromhome.vn
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/redmine.workfromhome.vn/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/redmine.workfromhome.vn/privkey.pem
Your cert will expire on 2020-06-25. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
Sử dụng trình duyệt và truy cập vào địa chỉ http://redmine.workfromhome.vn ta thấy đã được cài đặt chứng chỉ SSL

Cấu hình cho Let’s enscypt tự động gia hạn chứng chỉ SSL

echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" sudo tee -a /etc/crontab /dev/null

Như vậy là đã hoàn tất cấu hình trỏ domain và cài đặt SSL Let’s Enscypt cho Redmine trên hệ thống Cloud365

Mọi thắc mắc các bạn vui lòng liên hệ với Nhân Hòa để được hỗ trợ.

Cảm ơn các bạn đã theo dõi bài viết và chúc các bạn thành công.


Khi cần hỗ trợ xin liên hệ với chúng tôi:

Công ty phần mềm Nhân Hòa

24/08/2022

Trả lời