LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Forbid opening website through IP (https://www.linuxquestions.org/questions/linux-server-73/forbid-opening-website-through-ip-4175439916/)

canabizs 12-04-2012 01:28 AM

Forbid opening website through IP
 
Hi all,

I am interested how can I make that visitors CAN open my website only using hostname, but if they use IP directly they connection get refused?

For example, if I try to open website www.flip.lv everything is ok, but through it's IP address (37.59.9.81) I got connection refused or some other error (screen below).

http://i47.tinypic.com/1262oo5.png

TenTenths 12-04-2012 03:12 AM

As you don't give us any clues as to what you're using I'll assume apache as your web server.

Configure apache so that the default server for the IP has no content.

http://httpd.apache.org/docs/2.2/vhosts/examples.html and look at Using _default_ vhosts

canabizs 12-04-2012 01:33 PM

I don't know if it is made by web server or firewall or something else therefore I am asking this question.

Yes, I am using Apache2. Tried to set apache to redirect to 204 error (no content), but I still need to set destination url.

I want that when using IP address directly error is shown as there would not be even webserver running as on screen I attached.

canabizs 12-11-2012 12:07 PM

BUMP

bathory 12-11-2012 01:24 PM

Hi,
Quote:

I am interested how can I make that visitors CAN open my website only using hostname, but if they use IP directly they connection get refused?
You can give a 403 when someone uses the IP to access your server.
Code:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^37.59.9.81$
RewriteRule (.*) - [F]

Quote:

I want that when using IP address directly error is shown as there would not be even webserver running as on screen I attached.
If you like you can redirect the request to an IP with no webserver running

Cheers


All times are GMT -5. The time now is 05:17 AM.