Как установить Webmin с бесплатным SSL Lets Encrypt на Rocky Linux 8
На этой странице
- Предпосылки
- Установить Webmin
- Настройка Nginx в качестве обратного прокси-сервера для Webmin
- Включить SSL в Webmin
- Настройка Webmin
- Настройка брандмауэра
- Доступ к интерфейсу Webmin
- Заключение
Webmin — это бесплатный веб-инструмент для администрирования и управления Linux с открытым исходным кодом, который позволяет настраивать систему Linux через веб-браузер. Он написан на Perl и предоставляет удобный веб-интерфейс с мониторингом процессора и оперативной памяти в режиме реального времени. С Webmin вы можете выполнять несколько административных задач, включая управление учетными записями пользователей, управление пакетами, управление брандмауэром, создание заданий cron и многое другое.
В этом руководстве я покажу вам, как установить Webmin с Nginx и Lets Encrypt SSL на Rocky Linux 8.
Предпосылки
- Сервер под управлением Rocky Linux 8.
- Действительное доменное имя, указанное с IP-адресом сервера.
- На сервере настроен пароль root.
Установить Вебмин
Webmin написан на языке Perl, поэтому вам потребуется установить Perl в вашей системе. Выполните следующую команду, чтобы установить Perl:
dnf install perl -y
Затем загрузите последнюю версию архива Webmin с помощью следующей команды:
wget https://www.webmin.com/download/webmin-current.tar.gz
После загрузки Webmin извлеките загруженный файл с помощью следующей команды:
tar xvf webmin-current.tar.gz
Затем создайте каталог установки Webmin и запустите следующий скрипт для установки Webmin:
mkdir -p /usr/local/webmin
./webmin-1.984/setup.sh /usr/local/webmin/
Вам будет предложено указать путь к каталогу конфигурации, имя пользователя и пароль администратора, как показано ниже:
*********************************************************************** Welcome to the Webmin setup script, version 1.984 *********************************************************************** Webmin is a web-based interface that allows Unix-like operating systems and common Unix services to be easily administered. Installing Webmin from /root/webmin-1.984 to /usr/local/webmin/ ... *********************************************************************** Webmin uses separate directories for configuration files and log files. Unless you want to run multiple versions of Webmin at the same time you can just accept the defaults. Config file directory [/etc/webmin]: Log file directory [/var/webmin]: *********************************************************************** Webmin is written entirely in Perl. Please enter the full path to the Perl 5 interpreter on your system. Full path to perl (default /usr/bin/perl): Testing Perl ... Perl seems to be installed ok *********************************************************************** Operating system name: Rocky Linux Operating system version: 8.5 *********************************************************************** Webmin uses its own password protected web server to provide access to the administration programs. The setup script needs to know : - What port to run the web server on. There must not be another web server already using this port. - The login name required to access the web server. - The password required to access the web server. - If the webserver should use SSL (if your system supports it). - Whether to start webmin at boot time. Web server port (default 10000): Login name (default admin): admin Login password: Password again: Use SSL (y/n): n Start Webmin at boot time (y/n): y *********************************************************************** *********************************************************************** Webmin has been installed and started successfully. Use your web browser to go to http://rockylinux:10000/ and login with the name and password you entered previously.
По умолчанию Webmin прослушивает порт 10000. Вы можете проверить это с помощью следующей команды:
ss -antpl | grep 10000
Вы получите следующий вывод:
LISTEN 0 128 0.0.0.0:10000 0.0.0.0:* users:(("miniserv.pl",pid=6601,fd=7))
Настройте Nginx в качестве обратного прокси для Webmin
Рекомендуется использовать Nginx в качестве обратного прокси-сервера для Webmin. Сначала установите пакет Nginx с помощью следующей команды:
dnf install nginx -y
Затем создайте файл конфигурации виртуального хоста Nginx с помощью следующей команды:
nano /etc/nginx/conf.d/webmin.conf
Добавьте следующие строки:
server { listen 80; server_name webmin.linuxbuz.com; access_log /var/log/nginx/webmin.access; error_log /var/log/nginx/webmin.error; location / { proxy_pass http://127.0.0.1:10000; #proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
Сохраните и закройте файл, затем проверьте Nginx на наличие синтаксической ошибки:
nginx -t
Вы получите следующий вывод:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Затем запустите службу Nginx и включите ее запуск при перезагрузке системы:
systemctl start nginx
systemctl enable nginx
Вы можете проверить статус Webmin с помощью следующей команды:
systemctl status nginx
Вы должны увидеть следующий вывод:
? nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2022-02-12 08:20:04 UTC; 17s ago Process: 7051 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 7050 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 7048 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 7053 (nginx) Tasks: 2 (limit: 11412) Memory: 3.7M CGroup: /system.slice/nginx.service ??7053 nginx: master process /usr/sbin/nginx ??7054 nginx: worker process Feb 12 08:20:03 rockylinux systemd[1]: Starting The nginx HTTP and reverse proxy server... Feb 12 08:20:04 rockylinux nginx[7050]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Feb 12 08:20:04 rockylinux nginx[7050]: nginx: configuration file /etc/nginx/nginx.conf test is successful Feb 12 08:20:04 rockylinux systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument Feb 12 08:20:04 rockylinux systemd[1]: Started The nginx HTTP and reverse proxy server.
Включить SSL на Webmin
Рекомендуется защитить Webmin с помощью Lets Encrypt SSL. Во-первых, вам нужно будет установить клиент Certbot для управления Lets Encrypt SSL. Вы можете установить его с помощью следующей команды:
dnf install epel-release -y
dnf install python3-certbot-nginx -y
Затем запустите команду certbot, чтобы загрузить и установить Lets Encrypt SSL в домене Webmin.
certbot --nginx -d webmin.linuxbuz.com
Вам будет предложено указать свой действующий адрес электронной почты и принять условия обслуживания:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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. Requesting a certificate for webmin.linuxbuz.com Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/webmin.linuxbuz.com/fullchain.pem Key is saved at: /etc/letsencrypt/live/webmin.linuxbuz.com/privkey.pem This certificate expires on 2022-05-13. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. Deploying certificate Successfully deployed certificate for webmin.linuxbuz.com to /etc/nginx/conf.d/webmin.conf Congratulations! You have successfully enabled HTTPS on https://webmin.linuxbuz.com We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Настроить вебмин
Далее вам нужно будет отредактировать файл конфигурации Webmin и определить доверенных рефереров.
nano /etc/webmin/config
Добавьте следующую строку:
referers=webmin.linuxbuz.com
Сохраните и закройте файл, затем отредактируйте файл miniserv.conf и отключите режим HTTPS в Webmin:
nano /etc/webmin/miniserv.conf
Добавьте следующие строки:
ssl=0 allow=127.0.0.1
Сохраните и закройте файл, когда закончите.
Затем получите идентификатор процесса Webmin с помощью следующей команды:
ps -ef | grep webmin
Вы получите следующий вывод:
root 6601 1 0 08:12 ? 00:00:00 /usr/bin/perl /usr/local/webmin//miniserv.pl /etc/webmin/miniserv.conf root 7553 1117 0 08:24 pts/0 00:00:00 grep --color=auto webmin
Затем используйте команду kill, чтобы завершить процесс Webmin.
kill -9 6601
Затем запустите службу Webmin с помощью systemd и включите ее запуск при перезагрузке системы:
systemctl start webmin
systemctl enable webmin
Затем проверьте статус Webmin с помощью следующей команды:
systemctl status webmin
Вы получите следующий вывод:
? webmin.service - Webmin Loaded: loaded (/usr/lib/systemd/system/webmin.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2022-02-12 08:25:05 UTC; 54s ago Process: 7560 ExecStart=/etc/webmin/start (code=exited, status=0/SUCCESS) Main PID: 7561 (miniserv.pl) Tasks: 1 (limit: 11412) Memory: 23.9M CGroup: /system.slice/webmin.service ??7561 /usr/bin/perl /usr/local/webmin//miniserv.pl /etc/webmin/miniserv.conf Feb 12 08:25:05 rockylinux systemd[1]: Starting Webmin... Feb 12 08:25:05 rockylinux start[7560]: Starting Webmin server in /usr/local/webmin/ Feb 12 08:25:05 rockylinux webmin[7560]: Webmin starting Feb 12 08:25:05 rockylinux systemd[1]: webmin.service: Can't open PID file /var/webmin/miniserv.pid (yet?) after start: No such file or direc> Feb 12 08:25:05 rockylinux systemd[1]: Started Webmin.
Настроить брандмауэр
Если на вашем сервере установлен брандмауэр firewalld. Затем вам нужно будет разрешить порты 80 и 443 через брандмауэр. Вы можете разрешить их с помощью следующей команды:
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=443/tcp --permanent
Наконец, перезагрузите службу брандмауэра, чтобы применить изменения:
firewall-cmd --reload
Доступ к веб-интерфейсу
Теперь откройте веб-браузер и войдите в интерфейс Webmin, используя URL-адрес https://webmin.linuxbuz.com. Вы будете перенаправлены на страницу входа в Webmin:
Укажите имя пользователя и пароль администратора и нажмите кнопку «Войти». Вы должны увидеть панель инструментов Webmin на следующей странице:
Заключение
Поздравляем! вы успешно установили Webmin с Nginx и Lets Encrypt SSL на Rocky Linux 8. Теперь вы можете легко управлять своей системой Linux через веб-браузер. Не стесняйтесь спрашивать меня, если у вас есть какие-либо вопросы.