1

I can across a issue where I saw some xyz.com is pointing to mydomain.com. I am not using Apache, nor IIS but Tomcat 7 directly.

How to I avoid such other spam domains pointing to mydomain.com?

I read across some posts setting by virtual hosts etc, but nothing specific of how to avoid it. I searched on Google but most answers are for HTTP servers and no exact answer for tomcat 7.

Kenny Rasschaert
  • 9,045
  • 3
  • 42
  • 58

2 Answers2

3

You can't in any way stop anybody else from pointing to your webserver. What you can do is to server up a web site that will inform people that the domain is not hosted by you. There's some information about how virtualhosts work at the Tomcat documentation site.

If we assume that you have two domains that you want to host, and anything that doesn't match them should be shown the same "this domain doesn't live here" page, you'd have your first <Host ...> item be <Host name="localhost" ...>. That will be the default site loaded when there's no other site that matches. Then you'd add another <Host real.domain.com ...> for each of the domains that you actually want to serve.

In order to have the same content for two domain names, e.g. with/without "www", you use <Alias>www.mydomain.com</Alias> within the <Host> element.

And, for the "not my domain" page, you just create a separate application directory containing suitable web pages, and have that as the appBase for the "localhost" virtual host.

Jenny D
  • 27,780
  • 21
  • 75
  • 114
0

You can't. You don't control the other domain, and they can put whatever they want as the target of the CNAME or A record(s). The only thing you can do is refuse to serve the domain by making use of the virtual hosts in the documentation you found earlier.

John
  • 9,070
  • 1
  • 29
  • 34