Proxy using Sun ONE Reverse Proxy plugin

I have a web application hosted as http://www.domain-a.com. I am trying to setup reverse proxy for a site (say http://www.domain-b.com), so that when the user hits the URL http://www.domain-a.com/domain-b using his web browser, the web server proxies the request to the site http://www.domain-b.com, and then return response to the user as if the response was generated from http://www.domain-a.com. Further, any links & resources on the page should also appear as if originating from http://www.domain-a.com.

Platform:

Web Server: Sun ONE Web Server 6.1SP6 with Sun ONE Web Server 6.1SP3 Reverse Proxy Plug-in

OS: Windows XP Professional

Achieved so far:

I configured the reverse proxy plug-in as given below to make it work:

magnus.conf, to add the plug-in (lines added/modified as blue):

#

# The NetsiteRoot, ServerName, and ServerID directives are DEPRECATED.

# They will not be supported in future releases of the Web Server.

NetsiteRoot C:/Sun/WebServer6.1

ServerName dcsprintloaner1.sapient.com

ServerID https-dcsprintloaner1.sapient.com

#

RqThrottle 128

DNS off

Security off

ExtraPath C:/Sun/WebServer6.1/bin/https/bin

Init fn=flex-init access="$accesslog" format.access="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb.clf-request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%"

Init fn="load-modules" shlib="C:/Sun/WebServer6.1/bin/https/bin/j2eeplugin.dll" shlib_flags="(global|now)"

Init fn="load-modules" shlib="C:/Sun/WebServer6.1/plugins/nsapi/passthrough/passthrough.dll"

Init fn="stats-init" profiling="on"

obj.conf, to achieve reverse proxy (lines added/modified as blue):

# You can editthis file, but comments and formatting changes

# might be lost when the admin server makes changes.

# Use only forward slashes in pathnames--backslashes can cause

# problems. See the documentationfor more information.

<Object name="default">

AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"

NameTrans fn="ntrans-j2ee" name="j2ee"

NameTrans fn="pfx2dir" from="/mc-icons" dir="C:/Sun/WebServer6.1/ns-icons" name="es-internal"

NameTrans fn="assign-name" from="/domain-b" name="proxy-request1"

NameTrans fn="document-root" root="$docroot"

PathCheck fn="nt-uri-clean"

PathCheck fn="check-acl" acl="default"

PathCheck fn="find-pathinfo"

PathCheck fn="find-index" index-names="index.html,home.html,index.jsp"

ObjectType fn="type-by-extension"

ObjectType fn="force-type" type="text/plain"

Service method="(GET|HEAD)" type="magnus-internal/imagemap" fn="imagemap"

Service method="(GET|HEAD)" type="magnus-internal/directory" fn="index-common"

Service method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file"

Service method="TRACE" fn="service-trace"

Service method="(GET|HEAD)" type="*/*" fn="service-passthrough" servers="http://www.domain-b.com"

Error fn="error-j2ee"

AddLog fn="flex-log" name="access"

</Object>

<Object name="j2ee">

Service fn="service-j2ee" method="*"

</Object>

<Object name="cgi">

ObjectType fn="force-type" type="magnus-internal/cgi"

Service fn="send-cgi"

</Object>

<Object name="es-internal">

PathCheck fn="check-acl" acl="es-internal"

</Object>

<Object name="send-compressed">

PathCheck fn="find-compressed"

</Object>

<Object name="compress-on-demand">

Output fn="insert-filter" filter="http-compression"

</Object>

<Object name="proxy-request1">

Service type=magnus-internal/passthrough fn=service-passthrough servers="http://www.domain-b.com"

</object>

However, the end user could only see a 404 error (Page not found) when hitting the URL http://www.domain-a.com/domain-b. Following is the error from error log:

[09/Jan/2007:13:49:09] info ( 2596): CORE3274: successful server startup

[09/Jan/2007:13:49:31] warning ( 2596): for host 127.0.0.1 trying to GET /domain-b, send-file reports: HTTP4142: can't find C:/Sun/WebServer6.1/docs/domain-b (File not found)

I went through through some of the posting in this forums,and tried to replicate the suggestions at my end. However, I was not able to achieve the same. Please see if my approach is correct, and there is no issue with the configurations.

Thnx,

Amit

[6502 byte] By [alakraa] at [2007-11-26 14:37:03]
# 1

You instructed the Reverse Proxy Plugin to run only for the magnus-internal/passthrough MIME type, but you don't seem to set that MIME type anywhere. If you remove the type=magnus-internal/passthrough parameter from your Service directive, I'd expect things to work the way you want.

(I'm not sure what you expect the Service method="(GET|HEAD)" type="*/*" fn="service-passthrough" servers="http://www.domain-b.com" directive to do. It will never be executed.)

elvinga at 2007-7-8 8:18:00 > top of Java-index,Web & Directory Servers,Web Servers...
# 2

Hello Chris,

Thanks for the input.

Based on your suggestion, I removed the 'type' parameter. However, for some reason, I'm now getting 500 error (CANT_CONNECT_LOOPBACK).

Here is my modified obj.conf:

<Object name="default">

AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true"

NameTrans fn="ntrans-j2ee" name="j2ee"

NameTrans fn="pfx2dir" from="/mc-icons" dir="C:/Sun/WebServer6.1/ns-icons" name="es-internal"

NameTrans fn="assign-name" from="/domain-b" name="proxy-request1"

NameTrans fn="document-root" root="$docroot"

PathCheck fn="nt-uri-clean"

PathCheck fn="check-acl" acl="default"

PathCheck fn="find-pathinfo"

PathCheck fn="find-index" index-names="index.html,home.html,index.jsp"

ObjectType fn="type-by-extension"

ObjectType fn="force-type" type="text/plain"

Service method="(GET|HEAD)" type="magnus-internal/imagemap" fn="imagemap"

Service method="(GET|HEAD)" type="magnus-internal/directory" fn="index-common"

Service method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file"

Service method="TRACE" fn="service-trace"

Service method="(GET|HEAD)" type="*/*" fn="service-passthrough" servers="http://www.domain-b.com"

Error fn="error-j2ee"

AddLog fn="flex-log" name="access"

</Object>

<Object name="j2ee">

Service fn="service-j2ee" method="*"

</Object>

<Object name="cgi">

ObjectType fn="force-type" type="magnus-internal/cgi"

Service fn="send-cgi"

</Object>

<Object name="es-internal">

PathCheck fn="check-acl" acl="es-internal"

</Object>

<Object name="send-compressed">

PathCheck fn="find-compressed"

</Object>

<Object name="compress-on-demand">

Output fn="insert-filter" filter="http-compression"

</Object>

<Object name="proxy-request1">

Service fn="service-passthrough" servers="http://www.domain-b.com"

</Object>

Here is a view from my error logs:

[10/Jan/2007:09:53:32] info ( 2200): HTTP3072: [LS ls1] http://dcsprintloaner1.sapient.com:80 ready to accept requests

[10/Jan/2007:09:53:32] info ( 2200): CORE3274: successful server startup

[10/Jan/2007:09:53:53] warning ( 2200): for host 127.0.0.1 trying to GET /domain-b, service-passthrough reports: PASS1034: http://www.domain-b.com returned error code 500

Oh yes, w.r.t the Service directive, I included it by following the similar posts from the forum. And you may be right, as commenting the directive does not make any difference.

Is my configuration introducing a loopback request chain somewhere? And my idea is that my target URL (http://www.domain-b.com) is not the cause, as putting any third-party URL (for eg. http://www.google.com) is inducing the same behavior. Please suggest!

Thnx,

Amit

alakraa at 2007-7-8 8:18:00 > top of Java-index,Web & Directory Servers,Web Servers...
# 3

The error message indicates the Reverse Proxy Plugin made a request for http://www.domain-b.com/domain-b, and the server at www.domain-b.com responded with HTTP status code 500. That HTTP status code indicates a server error. It doesn't have anything to do with CANT_CONNECT_LOOPBACK.

(I'm very surprised to hear that www.google.com will respond to requests for http://www.google.com/domain-b with HTTP status code 500. It doesn't when I make requests for http://www.google.com/domain-b.)

If possible, inspect the logs of the www.domain-b.com web server. If that's not possible, you may need to do a protocol trace to figure out what's going wrong.

elvinga at 2007-7-8 8:18:00 > top of Java-index,Web & Directory Servers,Web Servers...