Showing posts with label glassfish. Show all posts
Showing posts with label glassfish. Show all posts

Monday, 25 May 2015

Updating Glassfish 4 in 64-bit OS

I wanted to upgrade from Glassfish 4.0 to 4.1 and "pkg image-update" didn't work for me since I was using 64 bit OS without 32-bit support libraries. There might be other problems as well: like described by SO question http://stackoverflow.com/questions/17033118/glassfish-updatetool-linux-64-bit-issue. I was surprised that Glassfish's pkg tool supports only 32 bit systems - and to run them on 64 bit OS-es, you have to install compatibility libraries...

We can fix that! Following the guidelines given in this blog post and updates from this forum post, we can run pkg using OS's built-in 64-bit python. All modified files I've put in this github poject. Here are the steps:
  1. Hit the "pkg" tool: /opt/glassfish/bin/pkg (it should fail)
  2. mv /opt/glassfish/pkg/bin/pkg /opt/glassfish/pkg/bin/pkg.orig
  3. Download modified pkg script and copy to /opt/glassfish/pkg/bin/pkg
  4. mkdir /opt/glassfish/pkg/custom-lib
  5. cp -r /opt/glassfish/pkg/vendor-packages/pkg /opt/glassfish/pkg/custom-lib
  6. Install the dependencies so that we can compile the _actions.c:
    apt-get install python-dev gcc python-cherrypy python-mako python-openssl python-ply python-pycurl python-simplejson
  7. Download _actions.c (you can clone the project if you have git installed on the server)
  8. gcc -I/usr/include/python2.7 -shared -fpic -O2 _actions.c -o _actions.so
  9. cp _actions.so /opt/glassfish/pkg/custom-lib/pkg/actions/_actions.so
  10. download __init__.py from the project folder
  11. cp __init__.py /opt/glassfish/pkg/custom-lib/pkg/actions/__init__.py
  12. enjoy
Hope this helps! This worked for me - hopefully it will work for you as well.

Thursday, 31 October 2013

Glassfish 4 behind (nginx) proxy

Problem: You want to put a proxy server (in this particular case it is nginx) in front of Glassfish 4 application server, but it ruins remote IP and scheme detection.

Solution consists of two main parts: (1) enabling "Auth Pass Through" property for HTTP connector and (2) configuring proxy server to add "Porxy-IP" and "Proxy-keysize" headers that will identify request scheme and remote IP address. Both header names are hard-coded and are not configurable.

First task is simple: open glassfish administration console and go to "Configurations" -> "server-config" -> "Network Config" -> "Network Listeners" -> "http-listener-1" and choose "HTTP" tab. Scroll all the way down and find "Auth Pass Through" property and enable it... "Save". No restart is needed (horray)!.

Second task - header configuration for nginx:

server {
        # listen 443;
        # ...

        # Glassfish-specific headers to properly resolve scheme and remote IP
        proxy_set_header        Proxy-IP  $remote_addr;
        proxy_set_header        Proxy-keysize 256;
        
        # ...
}

After changes, restart will be required. "Proxy-IP" header will be used in order to detect remote IP address, while having "Proxy-keysize" header greater than zero will force Glassfish to report schema as "https" (not "http"). It must be noted, however, that for non-SSL configuration only "Proxy-IP" header should be appended (otherwise non-SSL connections will be considered as secure):

server {
        # listen 80;
        # ...

        # Glassfish-specific headers to properly resolve remote IP and scheme
        proxy_set_header        Proxy-IP  $remote_addr;
        
        # ...
}

Important: Also consider setting proper proxy address in "General" tab in order to avoid security risks.

BTW, here's description for Apache's mod_proxy: http://www.manorrock.com/online/wiki/glassfish/UpgradeToGlassfish3