Thursday, July 16, 2015

Configuring Glassfish with Virtual servers behind nginx

I recently had to configure a virtual server on Glassfish behind nginx. I had to configure the virtual server to serve up a default application. Furthermore, I had to configure nginx to only accept HTTPS (SSL) requests to this virtual server.

I recorded quite a bit what I did. So I added in some fancy Powerpoint slides and uploaded the result to Youtube here.

The summary of steps I list here:

1. Install Glassfish and Nginx

(self explanatory)

2. Create a virtual server

To do this we do the following:

  1. Create a thread pool
  2. Create HTTP protocol (ignore the default virtual server setting for now)
  3. Create listener (ignore the default virtual server setting for now)
  4. Create virtual server
  5. Edit the listener (step #3) and protocol (step #2)

3. Create a self signed certificate

For development purposes, we create a self signed certificate. Of course for an actual production site, you'd need to buy it from a provider.

sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /Users/gerard/my_domain.key -out /Users/gerard/my_domain.crt

The above command will prompt for a common name. We then type the domain name that the certificate will be tied to.

4. Configure nginx

We tell Nginx to listen on the standard SSL port and to use the certificate for those connections.

server {
    listen       443 ssl;
        access_log  var/log/nginx/cas.access.log;

    ssl_certificate      /Users/gerard/my_domain.crt;
    ssl_certificate_key  /Users/gerard/my_domain.key;

    location / {
        proxy_pass http://localhost:28090;


No comments:

Post a Comment