Solved

ANYBODY? WE STILL NEED THAT!

Posted on 2004-08-03
9
233 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
[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
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 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