Come installare Webmin con Lets Encrypt SSL gratuito su Rocky Linux 8
Su questa pagina
- Prerequisiti
- Installa Webmin
- Configura Nginx come proxy inverso per Webmin
- Abilita SSL su Webmin
- Configura Webmin
- Configura firewall
- Accedi all'interfaccia Webmin
- Conclusione
Webmin è uno strumento di amministrazione e gestione di Linux gratuito, open source e basato sul Web che consente di configurare il sistema Linux tramite un browser Web. È scritto in Perl e fornisce un'interfaccia web user-friendly con monitoraggio in tempo reale di CPU e RAM. Con Webmin, puoi eseguire diverse attività amministrative tra cui la gestione degli account utente, la gestione dei pacchetti, la gestione del firewall, la creazione di cron job e altro ancora.
In questo tutorial, ti mostrerò come installare Webmin con Nginx e Lets Encrypt SSL su Rocky Linux 8.
Prerequisiti
- Un server che esegue Rocky Linux 8.
- Un nome di dominio valido indicato con l'IP del server.
- Sul server è configurata una password di root.
Installa webmin
Webmin è scritto in linguaggio Perl quindi dovrai installare Perl nel tuo sistema. Eseguire il seguente comando per installare Perl:
dnf install perl -y
Quindi, scarica l'ultima versione di Webmin tarball usando il seguente comando:
wget https://www.webmin.com/download/webmin-current.tar.gz
Una volta scaricato il Webmin, estrai il file scaricato con il seguente comando:
tar xvf webmin-current.tar.gz
Successivamente, crea una directory di installazione di Webmin ed esegui il seguente script per installare Webmin:
mkdir -p /usr/local/webmin
./webmin-1.984/setup.sh /usr/local/webmin/
Ti verrà chiesto di fornire il percorso della directory di configurazione, il nome utente e la password dell'amministratore come mostrato di seguito:
*********************************************************************** 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.
Per impostazione predefinita, Webmin è in ascolto sulla porta 10000. Puoi verificarlo con il seguente comando:
ss -antpl | grep 10000
Otterrai il seguente output:
LISTEN 0 128 0.0.0.0:10000 0.0.0.0:* users:(("miniserv.pl",pid=6601,fd=7))
Configura Nginx come proxy inverso per Webmin
È una buona idea utilizzare Nginx come proxy inverso per Webmin. Innanzitutto, installa il pacchetto Nginx utilizzando il seguente comando:
dnf install nginx -y
Successivamente, crea un file di configurazione dell'host virtuale Nginx con il seguente comando:
nano /etc/nginx/conf.d/webmin.conf
Aggiungi le seguenti righe:
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; } }
Salva e chiudi il file, quindi verifica Nginx per eventuali errori di sintassi:
nginx -t
Otterrai il seguente output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Successivamente, avvia il servizio Nginx e abilitalo per l'avvio al riavvio del sistema:
systemctl start nginx
systemctl enable nginx
Puoi controllare lo stato del Webmin con il seguente comando:
systemctl status nginx
Dovresti vedere il seguente output:
? 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.
Abilita SSL su Webmin
Si consiglia di proteggere il Webmin con Lets Encrypt SSL. Innanzitutto, dovrai installare il client Certbot per gestire Lets Encrypt SSL. Puoi installarlo con il seguente comando:
dnf install epel-release -y
dnf install python3-certbot-nginx -y
Successivamente, esegui il comando certbot per scaricare e installare Lets Encrypt SSL sul dominio Webmin.
certbot --nginx -d webmin.linuxbuz.com
Ti verrà chiesto di fornire il tuo indirizzo email valido e di accettare i termini di servizio:
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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Configura webmin
Successivamente, dovrai modificare il file di configurazione di Webmin e definire i referrer attendibili.
nano /etc/webmin/config
Aggiungi la seguente riga:
referers=webmin.linuxbuz.com
Salva e chiudi il file, quindi modifica il file miniserv.conf e disabilita la modalità HTTPS in Webmin:
nano /etc/webmin/miniserv.conf
Aggiungi le seguenti righe:
ssl=0 allow=127.0.0.1
Salva e chiudi il file quando hai finito.
Successivamente, ottieni l'id del processo Webmin con il seguente comando:
ps -ef | grep webmin
Otterrai il seguente output:
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
Quindi, usa il comando kill per terminare il processo Webmin.
kill -9 6601
Quindi, avvia il servizio Webmin con systemd e abilitalo per l'avvio al riavvio del sistema:
systemctl start webmin
systemctl enable webmin
Quindi, controlla lo stato di Webmin usando il seguente comando:
systemctl status webmin
Otterrai il seguente output:
? 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.
Configura firewall
Se il firewalld firewall è installato sul tuo server. Quindi, dovrai consentire le porte 80 e 443 attraverso il firewall. Puoi consentirli con il seguente comando:
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=443/tcp --permanent
Infine, ricarica il servizio firewall per applicare le modifiche:
firewall-cmd --reload
Accedi all'interfaccia Webmin
Ora, apri il tuo browser web e accedi all'interfaccia Webmin utilizzando l'URL https://webmin.linuxbuz.com. Verrai reindirizzato alla pagina di accesso di Webmin:
Fornisci il nome utente e la password dell'amministratore e fai clic sul pulsante Accedi. Dovresti vedere la dashboard di Webmin nella pagina seguente:
Conclusione
Congratulazioni! hai installato correttamente Webmin con Nginx e Lets Encrypt SSL su Rocky Linux 8. Ora puoi gestire facilmente il tuo sistema Linux tramite il browser web. Non esitate a chiedermi se avete domande.