
Monday July 23, 2007
Configuring reverse proxy in Sun Java System Web Server 7.0 when origin server is SSL enabled
Configuring reverse proxy in Sun Java System Web Server 7.0 when origin server is SSL enabled
In my
last blog I explained configuration of a simple non SSL reverse proxy. In this blog I have tried to set up a
scenario where a non SSL Sun Java System Web Server 7.0 tries to connect to origin server which is SSL enabled.
Creating SSL enabled origin server
If you already have an SSL
enabled origin server you can skip this.
For ease of use I have used SJS Web Server 7.0 as origin server also.
Start the administration
server, and go to wadm
>./wadm --user=admin
Please enter
admin-user-password> ****
- Create a self signed certificate
wadm>create-selfsigned-cert --config=test.sun.com
--server-name=test.sun.com --nickname=My-CA-Cert
- Create a HTTP listener
wadm> create-http-listener --listener-port=8888
--config=test.sun.com --server-name=test.sun.com
--default-virtual-server-name=test.sun.com mylistener
- Enable SSL for this listener and set the server certificate
wadm> set-ssl-prop --config=test.sun.com
--http-listener=mylistener
server-cert-nickname=My-CA-Cert enabled=true
- Deploy the changes
wadm> deploy-config test.sun.com
- Start this origin server instance.
Settings in Web Server 7.0 instance
Lets say we want to forward all
requests to /xyz to the origin server. Go the Web Server instance config directory and modify the obj.conf as given below
<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="/export2/mv/lib/icons" name="es-internal"
NameTrans
fn="map" from="/xyz" name="reverse-proxy-/" to="/xyz"
PathCheck fn="uri-clean"
...
</Object>
<Object
ppath="*">
Service
fn="proxy-retrieve" method="*"
</Object>
<Object
name="reverse-proxy-/">
Route
fn="set-origin-server" server="https://test.sun.com:8888"
</Object>
**Note that I have given manual steps here. In my last blog I have given Administration CLI steps.
Lets say for this instance server.xml has <port>8080</port>.
Make sure that the origin
server is up and running.
Start the server and access http://test.sun.com:8080/xyz/
should show you xyz directory in the docroot of the origin server.
Troubleshooting
In case we get a Gateway Timeout error
and in error logs we see some error like
[23/Jul/2007:16:44:11] failure
(27927): for host .... trying to GET ...., service-http reports:
HTTP7758: error sending request
(SEC_ERROR_UNTRUSTED_ISSUER: Client certificate is signed by an
untrusted issuer.)
We get this error because the origin server's certificate was not issued by a trusted CA. It means we need to export CA certificate of the origin server instance and import it into Web Server instance.
Export the origin server's CA certificate
Go to <server-instance>/config
directory of the origin server, and list certificates and then use pk12util to export the
certificate.
>../../bin/certutil
-L -d .
My-CA-Cert CTu,u,u
>../../bin/pk12util -o
/tmp/exported.crt -n My-CA-Cert -d .
Import the origin server CA certificate in server instance config
directory
Initialize NSS Database
To import certificate in server
instance config directory you have to first initialize the NSS database.
Note that if this Web Server instance is SSL enabled you can skip this
NSS database intialization part.
>../../bin/certutil -N -d .
Enter Password or Pin for "NSS
Certificate DB":
Re-enter password:
Password changed successfully.
Import the certificate
Lets say the file /tmp/exported.crt contained the
CA cert of the origin server, import that to NSS database.
> ../../bin/pk12util -i
/tmp/exported.crt -d . -v
Enter Password or Pin for "NSS
Certificate DB":
Enter password for PKCS12 file:
pk12util: PKCS12 IMPORT SUCCESSFUL
Confirm by listing certs
>../../bin/certutil -L -d .
My-CA-Cert u,u,u
Modify trust flags if required
You can see that the certificates
imported doesn't contain 'CT' trust flags.
>../../bin/certutil -M -n
My-CA-Cert -t 'CTu,u,u' -d .
Now u can see it is now a proper CA cert
>../../bin/certutil -L -d .
My-CA-Cert CTu,u,u
Restart the server instance and things should work fine now.
Posted by meena
( Jul 23 2007, 07:13:46 PM IST )
Permalink
Trackback URL: http://blogs.sun.com/meena/entry/configuring_reverse_proxy_in_web