LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 10-29-2013, 10:43 AM   #1
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Rep: Reputation: 18
Question Redhat/Apache 2.2.3 - Only allow single IP to access test site?


Hello all,

What I am trying to do is set up a virtual host for testing grounds that only my IP address will have access to. It seems no matter how I configure the virtual host in my httpd.conf file, it sends traffic to the default apache page.

Here is my config for the virtual host:
Code:
<VirtualHost *:80>
Servername test.example.com
DocumentRoot /path/to/test
<Directory /path/to/test>
     Options -Indexes ExecCGI SollowSymLinks
     Order Deny,Allow
     Deny from all
     Allow from 123.45.67.89
</Directory>
</VirtualHost>
I don't see where I have gone wrong. If I set it to Allow from all - it works fine.
The authz_host_module is enabled and loaded.

Thank you in advance, this is becoming quite frustrating.

mtlhd

Last edited by mtlhd; 10-29-2013 at 12:19 PM.
 
Old 10-29-2013, 11:05 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Try putting your "Allow from <ip>" before your "Deny from all" line.
 
Old 10-29-2013, 11:19 AM   #3
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
Thanks for the reply

TenTenths,

Thanks for chiming in, I just tested what you said and there was no change


-mtlhd
 
Old 10-29-2013, 11:27 AM   #4
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
What I do is put the directives in a .htaccess file in the relevant folder and just use:

Code:
Order Deny,allow
Allow from <Home IP>
Allow from <Work IP>
Deny from all
and this works for me.
 
Old 10-29-2013, 11:38 AM   #5
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
No cigar :(

Thanks for your help TenTenths,

I set my httpd.conf Virtual host to just have the options set and AllowOverride All then pasted the code setting you posted in an .htaccess file in the test directory.
Still sends me to a apache default page.

I just don't understand why it ignores all of the settings.

-mtlhd
 
Old 10-29-2013, 11:39 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
I've nothing else clever to suggest, except ensure you've the right IP address, if you're accessing the site from the server then try adding 127.0.0.1 as an Allowed IP.
 
Old 10-29-2013, 11:42 AM   #7
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Oh yeah, and ensure you have mod_authz_host loaded.
 
Old 10-29-2013, 11:48 AM   #8
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
when I ran httpd -M I saw authz_host_module (shared) on the list
 
Old 10-29-2013, 11:51 AM   #9
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by mtlhd View Post
Here is my config for the virtual host:
Code:
<VirtualHost *:80>
Servername test.example.com
DocumentRoot /path/to/test
<Directory /path/to/test>
     Options -Indexes ExecCGI SollowSymLinks
     Order Deny,Allow
     Deny from all
     Allow from 123.45.67.89
</VirtualHost>
Brain fade on my part, you're missing the </Directory> directive to close that block before the </VirtualHost>, so my guess is that your vhost isn't actually active and you're getting sent to the default site pages.
 
Old 10-29-2013, 11:55 AM   #10
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
Sorry, I don't know why I didn't type that in there, it is actually in the conf file with a closing directory tag. Failure on my part.
 
Old 10-29-2013, 11:57 AM   #11
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
And when you do a
Code:
httpd -S
your virtual host shows up?

Sorry, just covering all the things I can think of.

If this is on CentOS then also check your SELINUX settings and try disabling them and rebooting the server.
 
Old 10-29-2013, 11:59 AM   #12
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
Yea, showed up on the list with all of the others.
Once again, thank you for all your assistance with this issue.

-mtlhd
 
Old 10-29-2013, 12:07 PM   #13
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Code:
<VirtualHost *:80>
Servername test.example.com
DocumentRoot /path/to/test
<Directory /path/to/test>
     Options -Indexes ExecCGI SollowSymLinks
     Order Deny,Allow
     Deny from all
     Allow from 123.45.67.89
</VirtualHost>
well that code WILL send everything TO the not Virtuall page
it sends it to the main site defined in "documentroot"

see that port 80

THAT IS THE MAIN SITE!!
that is NOT the virtual site

the normal and set BY DEFAULT is port 8080

see the old 2.2 documentation
http://httpd.apache.org/docs/2.2/
- vhost-
http://httpd.apache.org/docs/2.2/vhosts/
urlrewrite--
http://httpd.apache.org/docs/2.2/rewrite/

Last edited by John VV; 10-29-2013 at 12:09 PM.
 
Old 10-29-2013, 12:32 PM   #14
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
Don't understand why the port would matter...All of my other vhosts run on it
The document root declaration within the virtual host is where my index file resides for the testing site. All of the other virtual hosts on this server are setup the same way and work.

The only difference with this test site is I am trying to deny traffic from the outside world and only give access to my ip address.

When I comment out:
Code:
Allow from 123.45.67.89
And change it to:
Code:
Allow from all
It works without any issue on port 80.

I don't know why, but but that very line breaks it. It then sends to the default page.

-mtlhd

Last edited by mtlhd; 10-29-2013 at 12:33 PM.
 
Old 10-29-2013, 01:39 PM   #15
mtlhd
Member
 
Registered: Sep 2007
Location: Florida
Distribution: Raspbian, Debian, CentOS, Ubuntu
Posts: 131

Original Poster
Rep: Reputation: 18
Now I understand what you mean, this only works on sub dirs

I'm not sure why, maybe it's the apache version, but on my home testing server (debian:apache 2.2.16) it worked fine.
On the production server (RHEL:2.2.3) it will not work.

-mtlhd

Last edited by mtlhd; 10-29-2013 at 02:22 PM. Reason: found my answer to be untrue
 
  


Reply



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 test SSL with Single apache Server Machine? your_shadow03 Linux - Newbie 1 10-26-2009 06:40 PM
Apache site redirects using what rule? foo.site.com -> www.site.com/foo LaughingBoy Linux - Server 2 04-16-2009 09:51 PM
Apache wont allow access to site created in Dreamweaver chuchulain64 Linux - Server 3 08-29-2007 09:22 AM
redhat 9 apache test page falcon777 Linux - Software 1 01-12-2004 11:12 AM
Is it possible to have more than one site on a single server? javaarmy Linux - General 1 10-12-2003 07:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:34 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
Open Source Consulting | Domain Registration