1

I have a Java Servlet called "ARI" which retrieves data from an archive database and returns an XML payload with rows from that database.

We have multiple instances of this servlet running on virtual servers from the one box and can be accessed by a different port number like so:

testserver.co.uk:61061/aricp/ari

testserver.co.uk:61062/aricp/ari

Both of these servlets can be accessed succesfully directly from the client here is a sample conversation between client and server taken by packet capturing.

Successfull HTTP Request:

POST /aricp/ari HTTP/1.1 Accept-Charset: UTF-8

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

User-Agent: Java/1.6.0_25

Host: testserver.co.uk:61061

Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2

Connection: keep-alive

Content-Length: 11

id=1-134ISR

note the POST variable "id" in the request

Successfull Response

HTTP/1.1 200 OK

Server: Sun-ONE-Web-Server/6.1

Date: Tue, 08 Jan 2013 17:48:49 GMT

Content-type: text/html

Transfer-encoding: chunked

03a6


*Successful HTTP Request Server Log *

[09/Jan/2013:10:25:33] fine (16359): for host 10.232.191.87 trying to GET /aricp/ari, ntrans-j2ee reports: mapped uri "/ari" in context "/aricp" to resource "ARI"

So it is ok to send direct requests to our servlet however if we use ZEUS ZXTM to indirectly handle requests from the client to all instances of our servlet it does not work.

Here is a failed HTTP Request note the difference in the HOST address as ZEUS is the intermediary.

ZEUS Failed HTTP Request

POST /aricp/ari HTTP/1.1 Accept-Charset: UTF-8

Content-Type: application/x-www-form-urlencoded;charset=UTF-8

User-Agent: Java/1.6.0_25

Host: zeus.co.uk:61061

Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2

Connection: keep-alive

Content-Length: 11

id=1-PUZK7D

ZEUS Failed HTTP Response

HTTP/1.1 404 Not found

Server: Sun-ONE-Web-Server/6.1

Date: Tue, 08 Jan 2013 18:05:45 GMT

Content-length: 292

Content-type: text/html

When using ZEUS the web server fails to interpret the request coming from ZEUS as a servlet request, instead it seems to interpret the request URI as a file path literally and we get a 404 not found.

ZEUS Failed HTTP Request Server Log

[09/Jan/2013:10:50:45] warning (16886): for host 10.232.184.53 trying to GET /aricp/ari, send-file reports: HTTP4142: can't find /u02/SunONE61060/docs/aricp/ari (File not found)

As you can see its treating the uri as a directory path instead of an application path.

This is a very strange problem.


Things I have tried

  • Removing the Access Control List to ensure no access was restricted
  • Refreshing servlet and virtual server
  • Refreshing ZEUS
  • Restarting Sun One Web server
  • Reinstalling servlet on virtual server

So in summary it is working fine like so:

Client --> Server

However it is not working when doing this:

Client --ZEUS --> Server

I am just about to go and refresh install of a new Virtual Server and see what happens.

Any ideas or theories welcome.

John Gardeniers
  • 27,262
  • 12
  • 53
  • 108
  • I don't believe this has anything to do with ZXTM, it looks like your backend application depends on the Host-header being set to `testserver.co.uk:61061`. Try a request directly from a client with a different Host header (via manipulating `/etc/hosts` or whatever) and see if it also fails. – faker Jan 09 '13 at 10:28
  • Thanks, I just figured out it has to do with my "urlhosts" in the virtual server settings. Is there a way to set multiple url hosts? – tomaytotomato Jan 09 '13 at 10:31
  • So if i set urlhosts = zeus.co.uk:61061 it works from ZEUS but now I cant access my servlet directly, which I suppose as a security aspect is quite good :S – tomaytotomato Jan 09 '13 at 10:40

1 Answers1

1

I'm unsure why you only have a single backend server maybe it's only a test setup.
ZXTM is a powerful load balancer, it seems you more or less use it as a reverse proxy currently.

Anyway, the way you usually setup something like this is:
- create a DNS record like myapp.example.com and point it to a traffic IP of the ZXTM cluster
- setup your backend application to listen to myapp.example.com
- create a virtual server in the ZXTM cluster which uses the traffic IP
- create a new pool in the ZXTM cluster and add testserver.co.uk:61061 to it
- assign the new pool to the created virtual server

You can then access your application via myapp.example.com.
You can still access the application directly on the backend nodes (e.g. for monitoring purposes) but depending on how the application works you might need to adjust the Host-header for this.

faker
  • 17,326
  • 2
  • 60
  • 69