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 = Network LAN = Network DMZ =

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_read_timeout  90;
    location /admin {
    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 '19 at 8:15
  • It shows the login page, but not with images and style. Then, when I log in the URL loses the /admin. Mar 23 '19 at 10:41

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 '' '/';
    sub_filter_once off;

For the redirect problem this could help:

proxy_redirect  /;


proxy_redirect /  /admin/;

Try this:

location /admin/ { 
    rewrite ^/admin/?(.*)$ /$1 break;
  • Welcome on the SU. Please explain, what it does and how.
    – peterh
    Mar 10 '20 at 11:00

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.