reen
reen

Reputation: 2502

Glassfish Server Webservice behind Apache HTTP Server

Hi We started to create our applications with J2EE. We now created a Webservice and deployed it to the Glassfish Server. We have written an apache proxy rule to access it via https://our.server.com/webservice-war (only https port is open to that server):

ProxyRequests Off
ProxyPass /webservice-war http://our.server.com:8080/webservice-war
ProxyPassReverse /webservice-war http://our.server.com:8080/webservice-war

Now everything works fine, but when we go to the to the ServiceEndpoint page (which is automatically generated) there is a link to the WSDL page: http://our.server.com:8080/webservice-war/HostaliasSearchImplService?wsdl

which is obously wrong (Glassfish listens to port 8080). and also https is changed to http

Anyone an idea how I can fix it, that the automatically generated link is:

https://our.server.com/webservice-war/HostaliasSearchImplService?wsdl

BR, Rene

Upvotes: 4

Views: 5121

Answers (4)

Aleksandar
Aleksandar

Reputation: 51

Setting

server-config.network-config.protocols.protocol.http-listener-1.http.server-name=MyHost:80

on GlassFish Server Open Source Edition 3.1.2.2 (build 5) solved problem to me.

Upvotes: 0

MikeThomas
MikeThomas

Reputation: 554

I discovered what I consider to be a very simple and elegant way to deal with the issue: use mod_substitute. Since those of us with this problem are already using Apache, and it's built in and simple, I liked this approach best.

I put a block similar to the below in one of my Apache conf files and found joy:

<Location />
   AddOutputFilterByType SUBSTITUTE text/xml
   Substitute "s|http://internal:8080/foo|https://external/foo|ni"
</Location>

Upvotes: 4

reen
reen

Reputation: 2502

Found the solution!

Anonym gave me a good hint about mod_jk. So here the complete configuration (for RHEL5).

First of all Download the mod_jk module for apache: http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/x86_64/

Put in in the modules directory /etc/httpd/modules and make it executeable:

chmod +x mod_jk-1.2.31-httpd-2.2.x.so

After that create /etc/httpd/conf/workers.properties:

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

The Port 8009 is the where the Glassfish jk connector listens (we come to that later).

No we have to configure mod_jk, therefore create the file: /etc/httpd/conf.d/mod_jk.conf with the following content:

LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.x.so
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel debug
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Send everything for context /atsi-war to worker named worker1 (ajp13)
JkMount /yourapp-war/* worker1

(This means everything from your http://apache.webserver.com/yourapp-war/ will bi redirected to Glassfish yourapp-war application context)

Important, if you are using virtual hosts on apache, you have to set the option: JkMountCopy On for your virtual servers. Explication:

If this directive is set to "On" in some virtual server, the mounts from the global server will be copied to this virtual server, more precisely all mounts defined by JkMount or JkUnMount.

Now we have to create the jk connecter in glassfish:

asadmin create-http-listener --listenerport 8009 --listeneraddress 0.0.0.0 --defaultvs server jk-connector
asadmin set configs.config.server-config.network-config.network-listeners.network-listener.jk-connector.jk-enabled=true

Restart Glassfish, and everything sould work.

Upvotes: 2

Anonym
Anonym

Reputation: 7725

As for rewriting the https -> http, I'm not sure that's possible(yet) without using mod_jk, see here , but see also this little guide

Though, generally, you'll need configure Glassfish and set http.proxyPort (and probably http.proxyHost too). Hopefully that should reflect in the autogenerated WSDL URL.

Here's 3 different ways to do this:

1 Use asadmin (in the Glassfish bin/ directory, run

asadmin create-jvm-options "-Dhttp.proxyPort=80"
asadmin create-jvm-options "-Dhttp.proxyHost=our.server.com"

2 Edit domain.xml and add under the <java-config> element

 <jvm-options>-Dhttp.proxyPort=80</jvm-options>
 <jvm-options>-Dhttp.proxyHost=our.server.com</jvm-options>

3. Open the Glassfish admin web page, under Application Server -> VM Settings -> JVM Options and add these options

http.proxyPort=80
http.proxyHost=our.server.com

Upvotes: 0

Related Questions