Welcome! Log In Create A New Profile

Advanced

Enable wildcard domains while disabling subdomains

Posted by nginx noob 
Enable wildcard domains while disabling subdomains
February 12, 2016 09:04PM
I have a one-click WP install strictly for parking domains for sale using a highly regarded plugin/theme that will display an offer form for any domain pointing at the server provided there is a DNS entry.

If the server block specifies "server_name _;" it works. However, you can create a subdomain just by visiting it such as pigglywiggly.example.com/

Is there a way to allow the primary domains by wildcard but not allow subdomains? I became suspicious when I saw eliminate-bacterial-vaginosis.example.com in my stats.

Thanks in advance for any solutions or suggestions.



Edited 1 time(s). Last edit at 02/12/2016 09:05PM by nginx noob.
Re: Enable wildcard domains while disabling subdomains
February 12, 2016 10:01PM
I think 'server_name www.example1.com example1.com www.example2.com example2.com;' is what you want.
Re: Enable wildcard domains while disabling subdomains
February 13, 2016 04:26PM
That's going to be more than inconvenient, that is impractical. There are 300+ domain names for sale, with many removed or added every day. By having the wildcard I don't have the 300+ domains actually in the config file, I just need to point the DNS to the IP#.

What I am asking is that every subdomain, even www, is not allowed on the HTTP port, such that the wildcard recognizes example.com but returns a 404 on requests for test.example.com, ssl.example.com and mail.example.com (mail, in fact, is handled by gmail, so no MX record is really necessary, but these are "hits" and "visits" I'm finding in my statistics log for the plugin). But example.com can be visited and the template for making an offer on just that domain is shown.

Perhaps I am not asking the question right either. If someone creates 4rrzz.com79wmwww.google.example.com (which only displays said template), what harm is there? Though it could be visited again, could it actually be abused? There are no pointers in var/www/html/wp-content/ showing such a "place."



Edited 2 time(s). Last edit at 02/13/2016 04:28PM by nginx noob.
Re: Enable wildcard domains while disabling subdomains
February 16, 2016 08:03PM
Hi. Would something like this work for you?

server {
listen 80 default;
server_name _;
return 200 'default\n';
...
}

server {
listen 80;
server_name ~^.*\..*\..*$;
return 444;
}

Testing with curl...

[root@nginx-splunk conf.d]# curl -H "Host:example123.com" localhost
default

[root@nginx-splunk conf.d]# curl -H "Host:example456.com" localhost
default

[root@nginx-splunk conf.d]# curl -H "Host:subdomain.example456.com" localhost
curl: (52) Empty reply from server

[root@nginx-splunk conf.d]# curl -H "Host:subdomain.example123.com" localhost
curl: (52) Empty reply from server

--Kevin
@webopsx
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 109
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready