LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2013, 07:15 AM   #1
sandeepc04
Member
 
Registered: Jun 2012
Location: India
Posts: 66

Rep: Reputation: Disabled
how to restrict access website by IP ?


Hi friends,

I have one issue with my apache virtual hosting...

I have registered one domain for my personal usage purpose (exp: sandeep.com), this sandeep.com hosting done in office linux rhel-5 server, For this hosting i have modified /etc/httpd/conf/httpd.conf file and mentioned below things in end of the file...

<VirtualHost *:80>
ServerAdmin root@www.sandeep.com
DocumentRoot /var/www/www.sandeep.com/html
ServerName www.sandeep.com
ServerAlias sandeep.com *.sandeep.com
ErrorLog logs/www.sandeep.com-error_log
CustomLog logs/www.sandeep.com-access_log common
</VirtualHost>

also given office public IP and sandeep.com in /etc/hosts file...

here i have 2 doubts,

1) whenever I access this website by direct public IP its opening as well as its opening with name (www.sandeep.com) , Here I don't want to open website by IP address, if office people open direct IP its showing my personal website in IP , that i dont want... How to avoid this issue? (on this office not configured any websites, just httpd service is running, even i dont want to open my personal website by IP address...)

2) when i try with (www.sandeep.com) its working fine but when i try for (sandeep.com) its redirecting to (http://sandeep.com) but not opening website.. its giving error on this...how can i make my site to access for "www.sandeep.com" "sandeep.com" http://sandeep.com) (http://www.sandeep.com)...


Thanks and Regards,
Sandeep CC
 
Old 10-03-2013, 07:23 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
The first host defined in apache becomes the default host when the server is accessed by IP, try changinc the order of the sites in your httpd.conf file.
If I remember correctly, the ServerAlias directive doesn't accept multiple arguments, so you'll need:
Code:
ServerAlias sandeep.com
And any other aliases defined individually.
 
Old 10-03-2013, 07:28 AM   #3
sandeepc04
Member
 
Registered: Jun 2012
Location: India
Posts: 66

Original Poster
Rep: Reputation: Disabled
TenTenths, Thanks for your quick reply...

1. Is not possible to keep apache default page for opening by IP? If I give IP then should come apache default page and if i give www.sandeep.com then my index.html page should come...

2. Yes (ServerAlias sandeep.com), I have tried with multiple options... even its not opening without www. (if i give sandeep.com then error is coming like The requested URL could not be retrieved)

Regards,
Sandeep CC

Last edited by sandeepc04; 10-03-2013 at 07:35 AM.
 
Old 10-04-2013, 01:43 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
That is a DNS issue, not a server configuration issue - you don't have an IP number assigned to the name sandeep.com.
 
Old 10-04-2013, 01:55 AM   #5
sandeepc04
Member
 
Registered: Jun 2012
Location: India
Posts: 66

Original Poster
Rep: Reputation: Disabled
hi jpollard,

Thanks for your reply,

actually sandeep.com i have registered in bigrock.com... there minimum we have to give one static IP... there only i have mentioned office static IP...(@ office server not running dns service, only activated httpd service for my virtual host, there s no other any office website to configure... Just i wanna get site open by name, by office IP should not open thats it...because its my personal work if someone come to know that i m using office IP , it wont look good thats the reason i am trying to remove website to access by IP...)

can you clear me where i am doing mistake?


Regards,
Sandeep CC
 
Old 10-04-2013, 04:46 AM   #6
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
there only i have mentioned office static IP...(@ office server not running dns service, only activated httpd service for my virtual host, there s no other any office website to configure
here you doing mistake... as stated above this is a DNS issue.
 
  


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
HOW can I Restrict (a laptop to just 1 Website) on Our wireless network- HOW? Wutz Linux Linux - Security 4 01-20-2013 07:08 PM
restrict volume access expatCM Ubuntu 13 05-08-2007 05:49 AM
Restrict X server access using /etc/security/access.conf anand_kt Linux - General 0 04-22-2005 09:40 AM
How to restrict website access in a LAN? mummrra Linux - Networking 3 12-05-2003 02:56 PM
Restrict access by IP waifurchin Linux - Security 3 02-02-2003 08:54 AM


All times are GMT -5. The time now is 02:30 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration