Tuesday, July 28, 2015

Maven Resources Filtering

I can never remember what its called. So I better make a blog post of it:


Basically allows us to copy strings from the POM, to any text based resources (e.g. XML, .properties files).

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;
        server_name  cas.gerardsetho.net;
        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;