?
Solved

Apache2 mod_rewrite / mod_proxy problem

Posted on 2005-04-05
4
Medium Priority
?
1,319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 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