Як захистити osTicket за допомогою SSL-сертифікатів Let’s Encrypt
У нас вже є статті, в яких йшлося про встановлення системи osTicket на системи CentOS 8 та Ubuntu Linux. У керівництві по установці веб-сервер Apache був налаштований на обслуговування системи osTicket по протоколу insure HTTP.
Якщо цільовою аудиторією системи osTicket є широка громадськість, доступ до якої здійснюється через інтернет, то існує необхідність захисту додатків за допомогою SSL/TLS. У цьому посібнику ми пояснимо всі кроки, необхідні для безпечного встановлення osTicket за допомогою безкоштовних SSL-сертифікатів Let’s Encrypt.
Ми використовуватимемо Certbot для запиту сертифікатів SSL від Let’s Encrypt Certificate Authority. Інструмент недоступний за замовчуванням, і його потрібно буде встановлювати вручну.
Крок 1: Встановіть інструмент генерації сертифікатів certbot
Встановіть certbot на Ubuntu /Debian:
# Install certbot on Ubuntu /Debian
sudo apt update
## Apache
sudo apt install python-certbot-apache
## Nginx
sudo apt install python-certbot-nginx
Встановіть certbot на CentOS 8 / CentOS 7:
У системі CentOS запустіть одну з наступних команд:
# RHEL 8 and Apache
sudo yum -y install python3-certbot-apache
# RHEL 8 and Nginx
sudo yum -y install python3-certbot-nginx
# CentOS 7 and Apache
sudo yum -y install python2-certbot-apache
# CentOS 7 and Nginx
sudo yum -y install python2-certbot-nginx
Крок 2: Оновіть конфігурації osTicket Apache
Змініть і запустіть наступну команду, яка дозволить отримати єдиний сертифікат за допомогою веб-кореневого каталогу /var/www/osTicket/upload.
sudo certbot certonly --webroot -w /var/www/osTicket/upload -d osticket.computingforgeeks.com
Де:
- /var/www/osTicket/upload є вебкоренем osTicket
- osticket.computingforgeeks.com – це домен із дійсним DNS Записом, що вказує на сервер хостингу
Введіть адресу електронної пошти, яка використовується для термінового поновлення та повідомлень про безпеку.
$ sudo certbot certonly --webroot -w /var/www/osTicket/upload -d osticket.computingforgeeks.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices)
(Enter 'c' to cancel): webmaster@computingforgeeks.com
Прочитайте та прийміть умови надання послуг:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
За бажанням ви можете погодитися поділитися своєю електронною адресою з Electronic Frontier Foundation:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, 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: Y
Account registered.
Нехай почнеться процес генерації сертифіката Encrypt:
Requesting a certificate for osticket.computingforgeeks.com and www.osticket.computingforgeeks.com
Performing the following challenges:
http-01 challenge for osticket.computingforgeeks.com
http-01 challenge for www.osticket.computingforgeeks.com
Using the webroot path /var/www/osTicket/upload for all unmatched domains.
Waiting for verification...
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Requesting a certificate for osticket.computingforgeeks.com
Subscribe to the EFF mailing list (email: webmaster@computingforgeeks.com).
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/osticket.computingforgeeks.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/osticket.computingforgeeks.com/privkey.pem
Your certificate will expire on 2021-06-27. To obtain a new or
tweaked version of this certificate in the future, simply run
certbot again. 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
Оновіть файл конфігурації Web Server osTicket, щоб він виглядав так:
Оригінальний файл конфігурації веб-сервера для osTicket:
$ sudo vim /etc/httpd/conf.d/osticket.conf
<VirtualHost *:80>
ServerAdmin webmaster@computingforgeeks.com
DocumentRoot /var/www/osTicket/upload
ServerName osticket.computingforgeeks.com
<Directory /var/www/osTicket/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/osticket_error.log
CustomLog /var/log/httpd/osticket_access.log combined
</VirtualHost>
Резервна копія файлу конфігурації http:
sudo cp /etc/httpd/conf.d/osticket.conf{,.bak}
Відкрийте файл для редагування:
sudo vim /etc/httpd/conf.d/osticket.conf
Вставте та змініть наведений нижче вміст, щоб оновити конфігурацію:
# osTicket configuration using Let's Encrypt SSL
<VirtualHost *:80>
ServerName osticket.computingforgeeks.com
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
</virtualhost>
<VirtualHost *:443>
ServerAdmin webmaster@computingforgeeks.com
DocumentRoot /var/www/osTicket/upload
ServerName osticket.computingforgeeks.com
<Directory /var/www/osTicket/upload/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog /var/log/httpd/osticket_error.log
CustomLog /var/log/httpd/osticket_access.log combined
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/osticket.computingforgeeks.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/osticket.computingforgeeks.com/privkey.pem
</VirtualHost>
Переконайтеся, що синтаксис конфігурації в порядку:
$ sudo /usr/sbin/httpd -t
Syntax OK
Перезапустіть службу httpd або apache2 в залежності від вашої операційної системи
# Ubuntu / Debian
sudo a2enmod rewrite expires
sudo systemctl restart apache2
# CentOS / RHEL
sudo systemctl restart httpd
Сервіс повинен повертати статус «Запущено»:
$ systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/httpd.service.d
└─php-fpm.conf
Active: active (running) since Mon 2021-03-29 12:30:26 UTC; 8s ago
Docs: man:httpd.service(8)
Main PID: 9299 (httpd)
Status: "Started, listening on: port 443, port 80"
Tasks: 213 (limit: 11232)
Memory: 27.7M
CGroup: /system.slice/httpd.service
├─9299 /usr/sbin/httpd -DFOREGROUND
├─9301 /usr/sbin/httpd -DFOREGROUND
├─9302 /usr/sbin/httpd -DFOREGROUND
├─9303 /usr/sbin/httpd -DFOREGROUND
└─9304 /usr/sbin/httpd -DFOREGROUND
Mar 29 12:30:26 osticket.computingforgeeks.com systemd[1]: httpd.service: Succeeded.
Mar 29 12:30:26 osticket.computingforgeeks.com systemd[1]: Stopped The Apache HTTP Server.
Mar 29 12:30:26 osticket.computingforgeeks.com systemd[1]: Starting The Apache HTTP Server...
Mar 29 12:30:26 osticket.computingforgeeks.com systemd[1]: Started The Apache HTTP Server.
Mar 29 12:30:26 osticket.computingforgeeks.com httpd[9299]: Server configured, listening on: port 443, port 80
Для конфігурації Nginx перевірте рецепт osTicket Nginx.
Продовження дії сертифікатів:
$ sudo /usr/bin/certbot renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/osticket.computingforgeeks.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not yet due for renewal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The following certificates are not due for renewal yet:
/etc/letsencrypt/live/osticket.computingforgeeks.com/fullchain.pem expires on 2021-06-27 (skipped)
No renewals were attempted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Для автоматичних продовжень за допомогою cron використання
# Ubuntu / Debian
sudo /usr/bin/certbot renew --pre-hook "systemctl stop apache2" --post-hook "systemctl start apache2"
# RHEL Based systems
sudo /usr/bin/certbot renew --pre-hook "systemctl stop httpd" --post-hook "systemctl start httpd"
Крок 3: Доступ до веб-порталу osTicket
Відкрийте веб-портал osTicket, щоб перевірити, чи завантажено сайт з https.
Якщо ви натиснете на кнопку блокування, вона повідомить вам, що з’єднання з сайтом безпечне.
Натисніть «More Information», щоб отримати більш детальну інформацію про сертифікат.
Ваша інсталяція osTicket тепер захищена SSL-сертифікатом Let’s Encrypt. Ми сподіваємося, що цей посібник був корисним.