PBMe_HikeIt
PBMe_HikeIt

Reputation: 679

IIS: Can I prevent traffic to IP Address and only allow domain name

Since I am using a host header filtering technique in my ASP.NET MVC application, I would like to prevent users from browsing directly to the IP address of my site, and force them to use the FQDN. Is this possible?

I see similar SO question here with no answer

Upvotes: 1

Views: 4245

Answers (2)

Ruikuan
Ruikuan

Reputation: 31

You can add another Website in IIS, locate it to an empty directory to make it don't do anything useful, use 80 port but don't bind any hostnames. In this case, who access your server by IP directly would just hit this Website, they won't bother you anymore.

Or maybe you can put some helpful webpages in this website to help your client visit by domain name correctly.

Upvotes: 1

Alan
Alan

Reputation: 116

You can do this with Bindings in IIS (assuming you're using IIS): https://technet.microsoft.com/en-us/library/cc731692(v=ws.10).aspx

  1. Open IIS
  2. Right click your site
  3. Click "Edit Bindings"
  4. Edit the entries (http/https) to include a "Host Name" (ex. "YourSite.com", "sub.YourSite.com", etc...)

An alternative would be to force a redirect to the FQDN in your code. You should be able to determine the url using a ServerVariable: https://msdn.microsoft.com/en-us/library/system.web.httprequest.servervariables(v=vs.110).aspx

Upvotes: 1

Related Questions