Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ANYBODY? WE STILL NEED THAT!

Posted on 2004-08-03
9
Medium Priority
?
246 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

971 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