How to enter Internal redirect URL overrides

SYSTEM INFORMATION
OS type and version Ubuntu 20
Webmin version Latest

I have my Webmin set up on port 2053 with Cloudflare, so I can control IP access externally through CloudFlare - if I do it in my server firewall or in Webmin I have no way to access it if I am on the road.

This does appear to create a security hole though: if someone accesses Webmin via my server’s IP, they can bypass CloudFlare. It strikes me that I could solve this problem by using Webmin’s Internal redirect URL overrides to redirect requests to my server’s IP on port 2053 to Webmin’s web address, but I cannot figure out how I am supposed to enter this. Can you explain it to me?

I fail to see the security hole. No Webmin security features depend on Cloudflare.

That’s not the point. The IP restriction (which is the best form of security) does depend on CloudFlare in my setup - as I said, if I implement this within Webmin or my server firewall I cannot access Webmin on the road, while CloudFlare allows me to temporarily add my IP. Even though I have all other security features apart from 2FA enabled as a backup (including Fail2Ban), I still would like to prevent bypassing of the IP restriction. I just need to know how to enter the Internal redirect overrides.

Isn’t the restriction done by Webmin, if your on the road and you get a different IP then you will need to update Webmin as cloudflare is bypasses.
Maybe I’ve read this wrong.

No it isn’t - if it was I would not be able to get into it in the first place when I am on the road. I restrict the 2053 port in Cloudflare, so I can add my IP as needed. But Cloudflare only works on the web address, not the IP address - hence my desire to redirect Webmin’s IP address to the web address.

In any case, even if you don’t understand what I’m trying to achieve, can somebody please just answer my simple question as to how to redirect Webmin’s IP to its web address?

I do not use CloudFlare, so may not be the best person to give advice … but am trying to fully understand your environment.

is this correct — you have a URL, say, example.com, that has its DNS hosted at CloudFlare, so users hit CF and then CF sends them (tunnels them?) to your real server using the real IP of the server.

if someone somehow finds out the IP of the real server, they can connect to ANY port on that server, including 80 and 443 and 2053.

what happens today if someone connects to port 80 directly into the server using its IP address (again the visitor/hacker somehow has discovered the IP of the server itself)? I am trying to draw comparisons to http/https traffic VS webmin traffic.

just guessing here — does CF tell you what IPs they use as they connect into you, so you can tell the difference between a direct connection (bad) and a connection coming thru CF (good)?

also I think I read that paid CF accounts have more features than a free account – do you have a paid or free account?

You basically have it right, but they can only connect to Webmin via port 2053, so that’s the only one I need to protect - 80 and 443 are open for real web traffic. And I am already redirecting server IP hits on these ports to the web address in Apache (it cannot bind to port 2053 though).

And no matter how much you pay, Cloudflare cannot protect the server IP - it only works via the DNS.

Yes, it is possible—edit the /etc/webmin/miniserv.conf file, add the following line to it, and restart Webmin:

musthost=host.domain.tld

Thanks Ilia! So just to make sure I’m understanding this correctly, what does ‘host’ mean in this case? The subdomain?

It refers to any domain name, whatever you choose to call it.

Okay, just too make sure, let’s say my Webmin address is https://webmin.mydomain.com:2053. So I would enter it as musthost=webmin.mydomain.com? Do I need to add the port number or the https://?

Yes, there’s no need for the port number.

I did it and it works. Thanks Ilia!

You’re welcome!

while you now have an answer to your specific question, I am not sure it fully solves your actual issue …

lets say your actual server is at 1.2.3.4 … all I need to do is edit my PCs HOST file to have webmin.mydomain.com locally defined as 1.2.3.4 and I’m in :smiley: Not sure now to protect from that.

on the other hand, I too learned something really neat (miniserv’s musthost config item) — thanks Ilia !!

With Ilia’s trick, Webmin will block access to anything other than the web URL, and that is protected by Cloudflare. So I don’t see how what you are suggesting would work.

Why not pm someone the ip of your server so @verne 's theory can be tested so the theory can be discounted ?

I tested it. It doesn’t work.

Note, Webmin 2.403 and later releases will include the option musthost_redirect=1 to enforce redirection to the desired host without showing an error.

So this will be in addition the current musthost directive to force redirection to the musthost URL, correct?