Putting Jenkins behind auth_basic Nginx reverse proxy

We have all been there and done that. And a simple Nginx reverse proxy with basic password authentication is no different. But what about putting Jenkins behind the reverse proxy?

What? So you're saying Jenkins changes the whole alchemy? Yeah boy. Jenkins and similar Tomcat Java based web apps that have their own authorization mechanism need to be treated differently behind a proxy. In fact you have to instruct them beforehand by adding the following header in your proxy block:

proxy_set_header Authorization "";

The whole nginx config may then look something like this:

server {
    listen 80;

    server_name jenkins.myserver.ltd;

    access_log /var/log/nginx/jenkins_access.log;
    error_log  /var/log/nginx/jenkins_error.log;

    location / {
      proxy_pass http://localhost:8080;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $host;
      proxy_set_header Authorization "";

      auth_basic "Restricted Content";
      auth_basic_user_file "/etc/nginx/.htpasswd";

Refactoring React components to ES6

Refactoring components to ES6 is going to be inevitable. The trickier parts imho are to refactor state initialisations and state functions.

State Initialisation

React is encouraging to move from getInitialState() to using constructor() method. Example:


In my opinion the code is cleaner...so I won't complain!

State Functions

React is removing our comfort zone of auto binding. This is to make is more Javascript idiosyncratic. Again, I won't really complain. Check the before and after example:


Since handleStartPress is going to manipulate the state, it needs to be binded manually to the class object (i.e. our component). Another clean way is to define the bind in the constructor() method:

Oracle XE 11g master-slave (standby replication) on Docker

In this demo I show how to setup two oracle XE 11g instances as Master Standby replication configured on two Docker containers.

How to fix an overheating Macbook (running sluggish and fan noise)

MacBooks are notorious for overheating - although there is a plethora of information out there how to fix this issue, most of the suggestions are either "Take it to Apple Care" or reset SMC.... In this post I am going to help you fix it for real, especially if it is a MacBook Pro 2010 in which case it is likely to be a hardware related issue.

In my opinion, an overheating MacBook causes two main nuances:

Problem 1 - If it overheats than there must be a hardware issue!
Problem 2 - MacBook overheats for no apparant reason even if it just sitting on your lap!
Problem 3 - The fans are whirling and creating lots of noise!
Problem 4 - The system runs sluggish when there is the overheating!

So let's tackle the sluggish issue first - I know it is a bit like cheating, but we will get to the root of the problem soon! Why does the MacBook run terribly slow during an overheat? Some of you may have fired up the Activity Monitor and noticed a process called kernel_task taking high CPU, sometimes even 400% !! So what is happening here?

Basically OSX has a kernel module called ACPI_SMC_PlatformPlugin that regulates the kernel and user processes to prevent overheating by trying to minimise the CPU cycles and system activity. This is done by constantly monitoring the temperature and inputs this information in a negative feedback system - the higher the temperature, it will tell the CPU to slow things down..you know..to chill a bit (that was good eh!).

So in theory this is a good thing. BUT...if there is a hardware fault - I will come to this later - this negative feedback system will actually worsen things out. So I suggest to eliminate this kernel module in the first place by running this command in your terminal:

The result is this: MacBook will still overheat for now, but at least will not cause the whole system to run super-slow and collapses your mental sanity. GOOD!

Now let's go to the hardware fault - I will talk about my experience but you can use the same troubleshooting and fix for your particular problem. So my MacBook was giving me trouble from day 1 - everytime I lay it down on my lap it will overheat in a few seconds. If I put it down on a couch, it will do the same. So I used to think that MacBooks in general do a terrible thing in compromising practicality for the sake of running sleek.

However one day I noticed while adding a RAM module that if I press on the RAM, the MacBook will suddenly overheat - so I started replicating the problem to be 100% sure - I was pressing down on the motherboard to make sure that it was just the spot on the RAM that was causing the issue. Further research gave me more insight and appeared to be a common problem!

So how did I fix this? This was easier now that I knew where was the problem. The fix is a bit of a household hack, but hey it works - I just folded a piece of paper and put it on top of the battery. This way I created a buffer and the lid was never pressing against the RAM module: