Solved

ANYBODY? WE STILL NEED THAT!

Posted on 2004-08-03
9
206 Views
Last Modified: 2010-03-04
...am giving away everything I have.

layout: we'd like to use mod_proxy with mod_rewrite together to replace hostname before submitting it to upstream proxy.

that is, user types, for example, http://www.icq.com/; then we rewrite it with http://10.0.2.7/.

so far we've managed to set up mod_proxy (it worx like any normal proxy). Now, when we add
<IfModule mod_rewrite.c>
 RewriteEngine On

 RewriteCond     %{HTTP_HOST}     ^.*\.icq\.com
 RewriteRule  ^/(.*)$  http://10.0.2.7/$1  [R]
</IfModule>

nothing happens. what should be correct rewrite rules/conditions ?
0
Comment
  • 4
  • 4
9 Comments
 
LVL 9

Expert Comment

by:rjkimble
ID: 11704772
What are you trying to accomplish exactly? You can incorporate proxying into your rewrite rules, but I have never done that. It seems to me that the point of mod_proxy is to make the browser think it's talking to one server while behind the scenes the conversation is being handed off to a second server. The point of mod_rewrite is to explicitly redirect the browser from the first server to the second.

You might consider adding an "L" to the "R" in your RewriteRule. Otherwise mod_rewrite keeps on looking for other rules to match, which is probably not what you want.
0
 
LVL 3

Author Comment

by:andYetAnotherLoginName
ID: 11704948
We need to "filter" out some of addresses and replace them with ours before submitting to mod_proxy.
0
 
LVL 9

Expert Comment

by:rjkimble
ID: 11705522
How about using the P flag as a rewrite rule?

For example:

<IfModule mod_rewrite.c>
 RewriteEngine On

 RewriteCond     %{HTTP_HOST}     ^.*\.icq\.com
 RewriteRule  ^/(.*)$  http://10.0.2.7/$1  [R,L]

 RewriteRule (your proxy rules goes here)
</IfModule>

The Apache docs for mod_rewrite give examples on using the P flag.
0
 
LVL 3

Author Comment

by:andYetAnotherLoginName
ID: 11705579
In this case 10.0.2.7 is local address. But, even if it was not, mod_rewrite is envolved before mod_proxy and the key problem is, as rewrite log shows, that no changes to URL are made.

Thus, it is about conditions/rules.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 9

Expert Comment

by:rjkimble
ID: 11705993
Are you sure that mod_rewrite is involved before mod_proxy? The order in which the modules are loaded affects the order in which they process requests. Is it possible that mod_proxy is firing first and sending the request along its way before mod_rewrite gets a chance to chime in? You might try inverting the order in which the two modules are loaded in httpd.conf (or whatever included file the import statements occur).
0
 
LVL 3

Author Comment

by:andYetAnotherLoginName
ID: 11706267
When I do that, rewrite log gets empty - because all URLs were processed by mod_proxy, I think. So I guess it is not the reason.
0
 
LVL 3

Author Comment

by:andYetAnotherLoginName
ID: 12015751
we have solved this. the key was "proxy:" part.

RewriteCond %{HTTP_HOST} ^(www\.)icq\.com [NC]
RewriteRule   ^proxy:http://www.icq.com/(.*)  http://205.188.248.121/$1 [P]

i want my points refunded.
0
 
LVL 9

Expert Comment

by:rjkimble
ID: 12016513
That's one I haven't seen before. You deserve your points back. Please don't ask to delete the question, however. The answer is good to know.
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 12018667
Closed, 260 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

912 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now