Glassfish server web service for Apache HTTP server

Hi We started creating our applications using J2EE. Now we have created a web service and deployed it to the Glassfish server. We wrote an apache proxy rule to access it through https://our.server.com/webservice-war (only the https port is open for this 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 ServiceEndpoint page (which is automatically created), there is a link to the WSDL page: http://our.server.com:8080/webservice-war/HostaliasSearchImplService?wsdl

which is terribly wrong (Glassfish listens on port 8080). and also https changes to http

Does anyone know how I can fix this, that an automatically generated link:

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

BR, Rene

+4
source share
4 answers

Found a solution!

Anonymous gave me a good hint of mod_jk. So, the full 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/

Insert / etc / httpd / modules into the modules directory and make it executable:

 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 

Port 8009 is where the jk Glassfish connector is listened to (we come to it later).

No, we need to configure mod_jk, so create a file: /etc/httpd/conf.d/mod_jk.conf with the following contents:

 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 that everything from http://apache.webserver.com/yourapp-war/ will be redirected to the context of the Glassfish yourapp-war application)

Important, if you use virtual hosts on apache, you need to set this parameter: JkMountCopy On for your virtual servers. Explication:

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

Now we need to create a jk connector in a glass fish:

 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 will work.

+2
source

I found that I consider a very simple and elegant way to solve this problem: use mod_substitute. Since those of us who have this problem already use Apache, and it was built-in and simple, I liked this approach best.

I put a block similar to the one below into one of the apache conf files and found the joy:

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

Regarding rewriting https -> http, I'm not sure if it's possible (yet) without using mod_jk, see here , but see also this little guide

Although, as a rule, you will need to configure Glassfish and install http.proxyPort (and possibly http.proxyHost too). We hope this should reflect on the auto-generated WSDL URL.

Here are three different ways to do this:

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

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

2 Modify domain.xml and add 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 โ†’ Virtual Machine Settings โ†’ JVM Settings and add these settings

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

Customization

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

GlassFish Server Open Source Edition 3.1.2.2 (build 5) resolved the issue for me.

0
source

Source: https://habr.com/ru/post/1339080/


All Articles