LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 12-04-2012, 02:28 AM   #1
canabizs
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Rep: Reputation: Disabled
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
 
Old 12-04-2012, 04:12 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6
Posts: 1,602

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
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
 
Old 12-04-2012, 02:33 PM   #3
canabizs
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.

Last edited by canabizs; 12-04-2012 at 02:59 PM.
 
Old 12-11-2012, 01:07 PM   #4
canabizs
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
BUMP
 
Old 12-11-2012, 02:24 PM   #5
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,975

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
website not opening SarahGurung Linux - Newbie 19 10-19-2011 04:11 AM
Forbid user from opening a file adrian2009 Linux - Newbie 2 03-24-2010 07:18 PM
youtube website not opening dragon88 Linux - Newbie 6 11-08-2008 12:36 AM
Opening a website in text mode HadesThunder Linux - Newbie 5 03-26-2004 07:20 PM
Problems with Linux Browser opening Website dolphans1 Mandriva 8 10-28-2003 08:50 PM


All times are GMT -5. The time now is 07:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration