Knowledge Base

Access to Netdata or Webmin or anything through a reverse proxy on any configured domain

Let's say you are using netdata or webmin or any other app that is using an alternative port to 80, and you want to secure your server a bit more, or perhaps it will be placed behind a very restrictive firewall, then you can use Nginx to forward the traffic from your regular site to the correct app by using folder names for them. So for example yoursite.com/netdata/. This is done by using thing called reverse proxy. It's very powerful and really easy to setup. The only thing you need to know is what port the app is using, and follow the examples below but just replace the name and port number. If you want to do this for netdata or webmin, you can just copy/paste what you see below.

The first part will go at the very top of your config file for your domain. Let's say you use a domain called example.com, then you need to place this in /etc/nginx/example.com.conf and make sure it goes BEFORE the server { block

upstream webmin {
    server 127.0.0.1:10000;
    keepalive 64;
}
upstream netdata {
    server 127.0.0.1:19999;
    keepalive 64;
}
virtual host config file

In the same config file we now need to jump to the server { block.Inside the server block It doesn't really matter where you paste these lines. I usually place it right below the first /location { block as shown in the screenshot below.

## NETDATA SETUP. Access it by entering /netdata at the end of your domain name. ##
        location = /netdata {
        return 301 /netdata/;
        }
        location ~ /netdata/(?<ndpath>.*) {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_pass_request_headers on;
        proxy_set_header Connection "keep-alive";
        proxy_store off;
        proxy_pass http://netdata/$ndpath$is_args$args;
        gzip on;
        gzip_proxied any;
        gzip_types *;
        }
## END NETDATA SETUP ##
## WEBMIN SETUP. Access it by entering /webmin at the end of your domain name. ##
        location = /webmin {
        return 301 /webmin/;
        }
        location ~ /webmin/(?<ndpath>.*) {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_pass_request_headers on;
        proxy_set_header Connection "keep-alive";
        proxy_store off;
        proxy_pass http://webmin/$ndpath$is_args$args;
        gzip on;
        gzip_proxied any;
        gzip_types *;
        }
## END WEBMIN SETUP ##

virtual host config file inside the block: server {

That's all!! Don't forget to do a nginx-t and then restart Nginx with: sudo systemctl restart nginx. Now you can open your webbrowser and type your domain name and add to the end /netdata. It should now display the netdata page.

Table of Contents