Solved

ANYBODY? WE STILL NEED THAT!

Posted on 2004-08-03
9
194 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 9

Expert Comment

by:rjkimble
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Closed, 260 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

12 Experts available now in Live!

Get 1:1 Help Now