ป้ายกำกับ: Subdomain Setup

Linux: Secure Webmin Access via Subdomain with NginxLinux: Secure Webmin Access via Subdomain with Nginx

Webmin is a web-based interface for system administration for Unix-like systems, providing a user-friendly way to manage server configurations. To enhance security, we can configure Nginx as a reverse proxy for Webmin, allowing access only through a specific subdomain and port 80. This setup ensures that Webmin is not directly exposed to the internet, reducing the risk of unauthorized access.

Configuring Webmin

To secure Webmin, we need to modify its configuration file. Open the Webmin configuration file located at /etc/webmin/miniserv.conf using a text editor. Add the following lines to the file:

SQL

referer=https://webmin.example.com
redirect_port=0
no_ip_check=1

Replace https://webmin.example.com with your desired subdomain. This configuration ensures that Webmin can only be accessed from the specified subdomain.

Setting Up Nginx

Next, we need to configure Nginx to act as a reverse proxy for Webmin. Create a new configuration file for your subdomain in the /etc/nginx/sites-available/ directory. For example, create a file named webmin.example.com.conf.

SQL

server {
    access_log /var/log/nginx/webmin.example.com-access.log;
    add_header X-Content-Type-Options "nosniff";
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    error_log /var/log/nginx/webmin.example.com-error.log error;
    http2 on;
    listen 443 ssl;
    location / {
        proxy_pass https://127.0.0.1:10000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }
    server_name webmin.example.com;
    #SSL Configuration
}

server {
    listen 80;
    return 301 https://webmin.example.com$request_uri;
    server_name webmin.example.com;
}

Replace webmin.example.com with your actual subdomain and ensure that the proxy_pass directive points to the correct port where Webmin is running (default is 10000).

Conclusion

By configuring Nginx as a reverse proxy for Webmin, you can enhance the security of your server management interface. This setup restricts access to Webmin through a specific subdomain and port 80, reducing the risk of unauthorized access. Always ensure that your SSL certificates are up to date and properly configured to maintain a secure connection.