Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Apache2 mod_rewrite / mod_proxy problem

Posted on 2005-04-05
4
Medium Priority
?
1,323 Views
Last Modified: 2012-06-27
Hi,

I want to serve a website wich is on a server in our DMZ (10.2.1.10).
There is one (apache) server connected to the internet (accessable by a few dns entries)

The main reason to block all exept IE is that the site contains material that should be only accessable by my colleages and they shouldn't be able to download the contents with ease.

I have this vitrualhost and it works great,

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://10.2.1.10/
ProxyPassReverse / http://10.2.1.10/
ServerName tst.no-ip.org
ErrorLog /var/log/apache2/error.log-nuggets
LogLevel notice
CustomLog /var/log/apache2/access.log-nuggets combined
ServerSignature On
</VirtualHost>

Considdering this site only supports IE, i want to redirect all other User Agents to an error page. Thus in comes mod_rewrite.
I've came up with this:

<VirtualHost *:*>
DocumentRoot /var/www/nuggets-test.iconnect.no-ip.org/
RewriteEngine On
RewriteLogLevel 9
RewriteLog "/var/log/apache2/tst-rewrite_log"
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$
RewriteRule / "http://10.2.1.10/index.html" [P,L]
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*$
RewriteRule / "http://tst.no-ip.org/error.html" [L]
ServerName test.no-ip.org
ErrorLog /var/log/apache2/error.log-nuggets
LogLevel notice
CustomLog /var/log/apache2/access.log-nuggets combined
ServerSignature On
</VirtualHost>

However, this does not work, i see no pictures/wrong style sheet. the rewriting seems to work ok.

I'm stuck, can anyone help me?
0
Comment
Question by:Noordeloos
4 Comments
 
LVL 16

Expert Comment

by:manav_mathur
ID: 13706065
You need possibly just one rewrite rule, that of the error

RewriteCond %{HTTP_USER_AGENT} ! MSIE
RewriteRule ^.*$ "http://tst.no-ip.org/error.html" [R]
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13714410
you redirect *any* request from non-IE to the same URL, hence a picture is also redirected to that URL
not shure if this works:

RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*$
RewriteRule / "http://tst.no-ip.org/error.html" [R,L]

oops, Manav still said this ;-)
0
 
LVL 1

Accepted Solution

by:
AlexeyZilber earned 1500 total points
ID: 13729523
Change:
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$
RewriteRule / "http://10.2.1.10/index.html" [P,L]

To:
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$
RewriteRule ^[/]?(.*) http://10.2.1.10/$1 [P,L]
0
 
LVL 3

Author Comment

by:Noordeloos
ID: 13734653
The P did the trick!
This is it now:


<VirtualHost *:*>
<Proxy *>
 Order Allow,Deny
 Allow from All
 Deny from 62.163.35.169
 Deny from 80.60.167.164
</Proxy>

ServerSignature On
ServerName test.iconnect.no-ip.org
RewriteEngine On
RewriteLogLevel 1
RewriteLog "/var/log/apache2/iconnect.no-ip.org/rewrite.log"
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE.*$      [OR]
RewriteCond %{HTTP_USER_AGENT} ^NSPlayer.*$      [OR]
RewriteCond %{HTTP_USER_AGENT} ^.*Windows-Media-Player.*$
RewriteRule ^/(.*) http://10.2.1.10/$1 [P,L]
RewriteCond %{HTTP_USER_AGENT} !^.*MSIE.*$      [OR]
RewriteCond %{HTTP_USER_AGENT} !^.*Windows.*$      [OR]
RewriteRule / "http://iconnect.bounceme.net/error.html" [L]

LogLevel info
ErrorLog /var/log/apache2/iconnect.no-ip.org/error.log
CustomLog /var/log/apache2/iconnect.no-ip.org/access.log combined
</VirtualHost>
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question