Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For one of the sub-paths, I am trying to restrict access only to Intranet originated requests. I tried following configuration, but it's not working as expected.

<VirtualHost *:7777>

Debug ON
RewriteEngine On
RewriteOptions inherit

RewriteRule   ^/$ /test1  [R,L]
RewriteRule   ^/test2$ -  [R=404] [L]

RewriteRule   ^/stage$ /stage/test1  [R,L]
RewriteRule   ^/stage/test2$ -  [R=404] [L]

<IfModule weblogic_module>
   WebLogicCluster localhost:7003,localhost:7005
</IfModule>

<Location /test1>
    SetHandler weblogic-handler
</Location>

<Location /test2>
    SetHandler weblogic-handler
</Location>

<Location /api>
    SetHandler weblogic-handler
    PathPrepend /test1
</Location>

<Directory /stage/test1>
    Order  deny,allow
    deny from all
    Allow from 192.168
    Allow from 127
</Directory>

<Directory /stage/test2>
    Order  deny,allow
    deny from all
    Allow from 192.168
    Allow from 127
</Directory>

<Directory /stage/api>
    Order  deny,allow
    deny from all
    Allow from 192.168
    Allow from 127
</Directory>

<Location /stage/test1>
    SetHandler weblogic-handler
    WebLogicCluster localhost:7203,localhost:7205
    PathTrim /stage
</Location>

<Location /stage/test2>
    SetHandler weblogic-handler
    WebLogicCluster localhost:7203,localhost:7205
    PathTrim /stage
</Location>

<Location /stage/api>
    SetHandler weblogic-handler
    WebLogicCluster localhost:7203,localhost:7205
    PathTrim /stage
    PathPrepend /test1
</Location>

</VirtualHost>

Can someone please help me resolving this?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

After consulting the apache doc again, use the following in your case

<Location /stage/test1>

    SetHandler weblogic-handler
    WebLogicCluster localhost:7203,localhost:7205
    PathTrim /stage

    Order deny,allow
    Deny from all
    Allow from 192.168.1.3 127

</Location>

Apply access restriction in location section.

share|improve this answer
    
I tried the following: <Directory /stage/test1> Order allow,deny Allow from 192.168.1.3 Allow from 127 </Directory> Where my IP address is 192.168.1.2 but I am able to access the page. Am I missing something? Sorry I could not get formatting correct. –  Pavan Dec 12 '12 at 6:18
    
do you have .htaccess in those directory overriding the restriction? –  John Siu Dec 12 '12 at 12:30
    
'/stage' is a re-direction path I am using, which will be PathTrim'd in <Location> section. –  Pavan Dec 19 '12 at 1:23
    
I did not pay attention before that you have redirection and then a location section. I revised my answer. –  John Siu Dec 19 '12 at 2:00
add comment

This worked, but I am not sure if it is cleaner way or not.

RewriteCond %{REMOTE_ADDR} !^10
RewriteCond %{REQUEST_URI} !^stage/(.*)
RewriteRule   ^/stage/(.*) -  [R=404] [L]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.