Way to hide proxied url?

New to mod_rewrite? This is a good place to start.

Way to hide proxied url?

Postby Wicaeed » Mon Oct 12, 2009 3:34 pm

Greetings,

Complete newbie to mod_rewrite here, hoping I can get some help.

I've started tooling around with mod_rewrite and mod_proxy, and am looking for a way to actually mask the url that is being proxied (is this the right term?).

I have it set up like so: You browse to www.internalwebsite.domain.com/novell and are redirected to www.novell.com/linux/

I want a way actually mask the fact that the website you are going to is Novell.com/linux, as well as mask the various url's that will come up as you browse the site, so to the user it would appear to be that they are browsing that website from within our own webserver, and the url never changes. This is just a silly task and has no bearing on anything important, but I'm stumped as to how to get this to work.

So far my .htaccess is configured as such:

#Turn on mod_rewrite
RewriteEngine On
Rewriterule novell http://novell.com/linux/? [P]

Obviously this is not going to do what I need to get this to work.

Any suggestions?
Wicaeed
 
Posts: 3
Joined: Mon Oct 12, 2009 11:59 am

Postby richardk » Tue Oct 13, 2009 2:13 am

What happens when you go to /novell?
Can you proxy to other domains (even your own internal website)?
Do you have access to the server configuration (httpd.conf file)?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^novell(/(.*))?$ http://novell.com/linux/$2 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Wicaeed » Tue Oct 13, 2009 8:16 am

When I go to the internal.domain.com/novell the url in the address bar changes from that to http://www.novell.com/linux. I see the difference between that is you can actually go to say, internal.domain.com/novell/partners.html and have it browse to novell.com/partners.html, valuable lesson learned I suppose :)

So that's halfway to what I need it to do. How do I go about rewriting the change so that any further browsing at novells website, I don't know, appents itself to the end of internal.domain.com/novell/, so any further browsing to internal.domain.com/novell/partners.html|communities.html|services_support.html| etc etc etc will actually browse novells site, but won't rewrite the domain that is in the address bar.

Sorry if I'm confusing you, I have no idea what to call what I am trying to accomplish (it's a learning task that has me completely stumped atm :) )

Would ProxyPass be a way to accomplish this?

And yes, I have this running on my own server so I have access to everything.
Wicaeed
 
Posts: 3
Joined: Mon Oct 12, 2009 11:59 am

Postby Wicaeed » Tue Oct 13, 2009 2:38 pm

I'mma go ahead and update my own thread here:

I have my vhost configured as such now:

Code: Select all

<VirtualHost proxytask.internal.com:80>

    ServerAdmin it@internal.com
    ServerName proxytask.internal.com:80
    DocumentRoot "/srv/www/vhosts/proxytask.internal.com/docs/"
    ErrorLog "/srv/www/vhosts/proxytask.internal.com/logs/error_log"
    CustomLog "/srv/www/vhosts/proxytask.internal.com/logs/access_log" combined
    RewriteLog "/srv/www/vhosts/proxytask.internal.com/logs/rewrite_log"
    RewriteLoglevel 9
    ProxyRequests On
    ProxyVia On
   
    <Directory "/srv/www/vhosts/proxytask.internal.com/docs/">
        Options Indexes FollowSymLinks
   AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

        <Proxy *>
        Order allow,deny
        Allow from all
        </Proxy>

        RewriteEngine On
        RewriteCond %{REQUEST_URI} ^/novell
        #ReWriteRule .* /userprofiles/$1.html [R,L]
        #ReWriteRule modrewrite http://www.modrewrite.com/? [NC,R,L]
        #Rewriterule (.*) http://novell.com/linux/ [P]
        RewriteRule "^/novell(.*)$" http://novell.com/linux/ [L,P]
        #ProxyPass /novell/ http://novell.com/linux/
        #ProxyPassReverse /novell/ http://novell.com/linux/


</VirtualHost>


According to my two bosses this SHOULD be working, but it doesn't, if I go to my rewrite log when I go from proxytask.internal.com to proxytask.internal.com/novell it displays this:
Code: Select all
192.168.1.153 - - [13/Oct/2009:13:08:21 --0700] [proxytask.internal.com/sid#80164fc8][rid#802ece20/initial] (2) init rewrite engine with requested uri /novell
192.168.1.153 - - [13/Oct/2009:13:08:21 --0700] [proxytask.internal.com/sid#80164fc8][rid#802ece20/initial] (3) applying pattern '^/novell(.*)$' to uri '/novell'
192.168.1.153 - - [13/Oct/2009:13:08:21 --0700] [proxytask.internal.com/sid#80164fc8][rid#802ece20/initial] (4) RewriteCond: input='/novell' pattern='^/novell' => matched
192.168.1.153 - - [13/Oct/2009:13:08:21 --0700] [proxytask.internal.com/sid#80164fc8][rid#802ece20/initial] (2) rewrite '/novell' -> 'http://novell.com/linux/
192.168.1.153 - - [13/Oct/2009:13:08:21 --0700] [proxytask.internal.com/sid#80164fc8][rid#802ece20/initial] (2) forcing proxy-throughput with http://novell.com/linux/
192.168.1.153 - - [13/Oct/2009:13:08:21 --0700] [proxytask.internal.com/sid#80164fc8][rid#802ece20/initial] (1) go-ahead with proxy request proxy:http://novell.com/linux/[OK]


According to my bosses, this is what a correct proxy request should look like, but the content is not really being proxied, it is being redirected.

What is my problem here? I am so utterly confused atm :(
Wicaeed
 
Posts: 3
Joined: Mon Oct 12, 2009 11:59 am

Postby richardk » Tue Oct 13, 2009 2:46 pm

Is it being redirected by your server or novell's server? In fact, i think it's the "force www" redirect on novell's server.

As you have access to the server configuration you can use mod_proxy
Code: Select all
ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /linuxv http://www.novell.com/linux
ProxyPassReverse /linux http://www.novell.com/linux
ProxyPassReverseCookieDomain proxytask.internal.com www.novell.com
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 35 guests

cron