homepage Welcome to WebmasterWorld Guest from 54.166.122.65
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod rewrite to proxy
dariusf



 
Msg#: 4618858 posted 6:29 pm on Oct 24, 2013 (gmt 0)

Hi, I'm new to mod_rewrite and I need to setup a proxy on my clients server.

What we need is to inspect the requested URL and proxy the request to outside server. The returned content should appear to the browser as coming from our domain.

The URL calls are dynamic and we don't to control the full URL only the domain and the first directory in the request. The rest will be dynamic.

example request:

https://www.mysite.com/videothumb/unsecured/media/1301119679001/23764.jpg?pubId=1301119679001

needs to proxy to:

http://www.othercomp.com/unsecured/media/1301119679001/23764.jpg?pubId=1301119679001


I need to catch and proxy any request that starts with this URL: https://www.mysite.com/videothumb/ while maintaining the rest of the path/file/params.

I tried to add this to the httpd-vhosts.conf at the end of the <VirtualHost> section with no luck


RewriteRule ^videothumb/(.*)$ http://www.othercomp.com/$1 [P]


Any ideas how to accomplish this?

Thank you for your help

 

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4618858 posted 7:59 pm on Oct 24, 2013 (gmt 0)

I tried to add this to the httpd-vhosts.conf at the end of the <VirtualHost> section with no luck

RewriteRule ^videothumb/

Is this rule inside a directory section? If not, it would need a leading slash. For insurance, try it without the opening anchor.

I'm assuming you have other RewriteRules in the same section, so the RewriteEngine is already on.

Does "no luck" mean that, as far as you can tell, nothing happened at all? Or did the wrong thing happen?

dariusf



 
Msg#: 4618858 posted 8:15 pm on Oct 24, 2013 (gmt 0)

Thank you for the reply, yes there are other rules before this one and working fine. By nothing happens, I mean the proxy is not taking place and the request results in 404.

You mean try it like this:


RewriteRule /videothumb/(.*)$ http://www.othercomp.com/$1 [P]
or
RewriteRule videothumb/(.*)$ http://www.othercomp.com/$1 [P]

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4618858 posted 4:00 am on Oct 25, 2013 (gmt 0)

A form with neither an anchor nor a slash will always work everywhere. So try that first. If pattern format isn't the problem, we'll dig deeper.

Can we also assume that mod_proxy is enabled? It would be a pretty embarrassing oversight-- but you wouldn't be the first!

dariusf



 
Msg#: 4618858 posted 12:16 pm on Oct 26, 2013 (gmt 0)

yes its is on :) first thing I confirmed.

RewriteEngine on

I tried


RewriteRule ^videothumb/(.*)$ http://www.othercomp.com/$1 [P]
RewriteRule /videothumb/(.*)$ http://www.othercomp.com/$1 [P]
RewriteRule videothumb/(.*)$ http://www.othercomp.com/$1 [P]


with no luck. Yes, I did restart apache after each change.

I'm not clear if I need ProxyPassReverse as well?

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4618858 posted 9:28 pm on Oct 26, 2013 (gmt 0)

While waiting for someone who speaks Apache:

Are you on 2.2 or 2.4? The present thread doesn't seem to say, and it may end up making a difference.

System
redhat


 
Msg#: 4618858 posted 1:14 am on Oct 27, 2013 (gmt 0)

The following 4 messages were cut out to new thread by incredibill. New thread at: apache/4619305.htm [webmasterworld.com]
10:46 pm on Oct 26, 2013 (PST -8)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved