How make sure your server does not respond for that domain respectively returns an appropriate error message when a request for it comes in

**OS type and version:Ubuntu 20.04
**Webmin version:Latest
**Virtualmin version:Latest
**Related products version:

I need to assure that my vps dont respond to some unknown subdomains that is pointed to my ip. Anybody that can help?

Ok, you want your VPS to ‘not respond’ to some websites which have been pointed to.the IP address of your VPS. My suggestion is to get your server to respond, but in a manner that consumes minimal resources.

One way to do this would be to redirect the unwanted sub-domains to Google or some charity website that you feel kindly towards. A redirect would put very little strain on the VPS.

In addition to your desired outcome of getting your server to ‘not respond’ if you had also let us know what your pain point is with the way things current stand - e.g. logs getting populated and analytics getting skewed - then the community could respond with relevant suggestions but getting a server to ‘not respond’ is against norms and RFC specs.

Also meaningful would be the number of undesired sub-domains. If these are few enough in number to process manually, then just create a virtual server for each undesired sub-domain and let the default Virtualmin under construction page show for all URLs under those sub-domains.

Since I write I decided to redirect the requests from these domains to an errorpage. That works but as I understand I need to do it for every subdomain, and it come one new per hour about. I cant use wildcards in the rewrite I think, or? I am also loking into how to use cloudflare to only allow requests from their ip range.

I ask again, what is your pain point / problem if someone is pointing undesired domains to the IP address of your server?

If someone had done that to me, my server would respond with the appropriate error message and I would be fine with that. Why is this outcome not fine with you?

1 Like

The painpoint is more that it is annoying to have to check once per hour if any new subdomains show up and the edit the htaccess. I can use my time better. The site btw is

Virtualmin has a default site option. This default site gets served to requests that don’t match any domain or subdomain configured on the server.
Just set up your “default site” and you can handle those requests there. The response page still appears at the address entered by the user, so you can use the host header in your code to customize the output.

1 Like

What? No. You don’t add those domains to your server. Just make a “default” domain that is whatever you want it to be. If that’s an error page, that’s fine. If it’s your business primary domain website, whatever.

If you have no legit subdomains at all and don’t use www, then I think this would work to redirect them all to your main site:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.earthfightsback\.org$   [NC]
RewriteRule ^  [L,R]

If you do use www, then this should work:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.earthfightsback\.org$   [NC]
RewriteCond %{HTTP_HOST} !^www\.earthfightsback\.org$  [NC]
RewriteRule ^  [L,R]

Try it first though. That’s just off the top of my head and not tested.

I think a redirect to the home page is more productive than an error page, especially since the site is trying to proclaim a message.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.