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 |
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 |
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 |
That is a DNS issue, not a server configuration issue - you don't have an IP number assigned to the name sandeep.com.
|
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 |
Quote:
|
All times are GMT -5. The time now is 12:38 PM. |