0

I am setting up an NGINX to be a WAF (Web Application Firewall).

NGINX reverse proxy is working fine for https://hostname/, but I would like to make https://hostname/admin to be proxied into a Webmin interface.

The scenario is as follows: Internet NET = 0.0.0.0/32 Network LAN = 6.0.0.0/8 Network DMZ = 11.0.0.0/8

As NET=(router)=LAN=(nginx)=DMZ=(a few virtual machines) |--->dmz>---|

So far all is working fine, but now I want to create a Webmin into each virtual machine to be accessed by adding /admin at the end of the hostname

such as https://nas/admin

An example of the configuration file located in /etc/nginx/sites-enabled is:

server {
    listen 443 ssl; # managed by Certbot
    server_name nas;
    location /.well-known {
            alias /var/www/nas/.well-known;
    }
    location / {
        proxy_buffers 16 4k;
        proxy_buffer_size 2k;
        proxy_set_header        Host $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;
        proxy_pass          https://11.0.0.12:443;
        proxy_read_timeout  90;
    }
    location /admin {
        proxy_pass          https://11.0.0.12:10000;
    }
    client_max_body_size 10G;
    ssl_certificate /etc/letsencrypt/live/nas/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nas/privkey.pem;
}

server {
    listen 80;
    server_name nas;
        return 301 https://$host$request_uri;
}

What am I doing wrong?

  • Do you get any error/error code? What exactly is not working? Have you made a port forwarding in the firewall for nginx accessing a different network? – unNamed Mar 22 at 8:15
  • It shows the login page, but not with images and style. Then, when I log in the URL loses the /admin. – Danilo Souza Mar 23 at 10:41
0

For the problem losing the images/styles:

The Webmin interface probably uses a mix of relative and absolute paths. That's why you don't get the images. You need the sub module: --with-http_sub_module

Something like this could help:

location /admin {
    sub_filter 'https://11.0.0.12:10000/' '/';
    sub_filter_once off;
    proxy_pass          https://11.0.0.12:10000;
}

For the redirect problem this could help:

proxy_redirect https://11.0.0.12:10000/  /;

or

proxy_redirect /  /admin/;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.