Category Archives: Software

Software related topics

Apache Load balancing a Django App

So I am trying to test my picture storage app in a load balancing environment.
I got the client all set up to point at the load balancer and all the instances in the farm are up and running.

When I try to login from the client application, I always get a “Username/password pair do not match”. So what could be the problem ? It was working fine on my machine (typical developer lame escuse)

Looking into the apache logs of the server machines I noticed that the HTTP_AUTHORIZATION http header was missing when the login request was reaching the servers. So I started to find where in the request path the header was being lost.

I started suspecting the load balancer was stripping the headers from the request and not passing it to the app servers. Below is the configuration of the load balancer :

<Proxy balancer://django>
BalancerMember http://django1 ping=5 disablereuse=on retry=5 ttl=120
BalancerMember http://django2 ping=5 disablereuse=on retry=5 ttl=120
BalancerMember http://django3 ping=5 disablereuse=on retry=5 ttl=120
</Proxy>
ProxyPass "/*" "balancer://django"
ProxyPassReverse "/*" "balancer://django"
I searched the net and could not find any hint that apache load balancing did anything special to the request headers.
So I tried looking at the receiving end of the process. I even had a couple of log statements on the authentication class on the server that logged the request headers and the request path.
I even added a header to the client and the server that had a custom name so to eliminate the hypothesis that only the authorization header was being stripped from the request.
Upon inspection of those log statements I found that neither the authorization header nor the custom header reached the authentication code.
So I started suspecting the apache server on each server that serves the app through mod_wsgi. While searching for a way to log the headers coming in to apache I came to know about the mod_log_forensic.so module. Since I had compiled apache on a similar machine to the server ones I just copied the .so to those apache installations and installed them.
Ran some tests again, and observed that the server apaches were in fact receiving both headers. So I nailed it down to the mod_wsgi python module.
So I did another search on Google for “request.META missing headers”. I came across a Stack Overflow post that finally cleared the mistery. Here’s the link to the post :
My custom header had an underscore, and for security reasons mod_wsgi removes headers with those characters from the  request. See the post on why it does that. So now my custome header is reaching the authentication code with a “HTTP_” string prepended. That’s what mod_wsgi does to http headers, so that’s fine.
Now to tackle the real issue. Why is the “Authorization” header not getting through. Well, the previous SO post I mentioned before talks about another post that explains that :
In the post there are two possible solutions :
– configure mod_wsgi
– use url rewriting to pass the header
I prefer the former, so that’s what I did, and it did the trick.

The countryside

I live in the country side. Well, sort of. There are many open spaces nearby, which I take advantage of to make ocasional walks, breathing the fresh air and contacting with nature. Since I work in an  office building on a desk job, these are moments to relax, perspire and bond with all other living things.

The region is a wine producer, so there are many vines in the vicinity of were I live.

At the moment the weather is kind of humid so the vegetation is vibrant and very green.

Right now I am blogging this from my parent’s house in their home town, which is in the southern part of the country. Maybe next week I will post about this trip down south.

Cheers

 

 

Printer teardown

Hi!

I am in the process of tearing apart an old printer. So far not troublesome, but some screws have their heads shot, so I cannot use a screw driver with them. The printer has a cool motor on it that I intend to salvage for future projects. Below is the current status of the disassembly.

GNUStep on ARM

I have recently installed the GNUStep ecosystem of applications and libraries on my retroPie installation. The package manager has the base system and some applications.

After installing some I noticed that there are bugs in those releases that might have been fixed in later versions. For example Project Center was unable to open the Makefiles of a project in the editor. Seemed like a very basic problem, so I downloaded the latest source and built it. Problem gone.

Another cool app is GNUMail. The distributions stock package had problems connecting to the gmail mail server. So I downloaded the source and built it. I can now connect to the mail server, but the UI is buggy. Parts of the text are hidden unless you click on it. And it crashes easily when opening messages.

So I have decided to build everything from the latest sources, and probably do some bug fixing if time permits.

Playing Super Mario on NES

Finally moved my retro pie PI3 to the living room. Using a wireless keyboard and mouse and my PS4 controller I can now play all those abandonware games on the net. I even installed the X server on it and firefox to browse the web when I am not playing. It looks very good at Full HD resolution on the big screen tv.

Now I need to install the PI on the plastic box I got for it (which by the way is totally crap, but it’s the only one I have now)

My happy place

I wish I could be at my happy place all day. I have a ton of personal projects currently, but to eat I am forced to leave the house  and work at a day job. Not that I dislike the day job but I feel that I am working not for myself but to others.

Below is my main workstation, where I code the software projects I am working on.

Below Is the workstation in my home studio where I record and edit music, and also play some games when time allows me.

When I am at work I frequently visit my own blog that has all these pictures and dream of getting home and doing stuff for myself.

Book shelf

Some months ago I went on a book shopping spree. I ended up with over 60 new books in my library. Even had to go to IKEA to buy a shelf to put them in. They are all tech related books, mostly on software development, IT automation (to manage the Iron at the office, see last post) and electronics.

The Objective is to fill the shelve with tech books, I will be in the market for future additions that are relevant for what I am doing currently at home (the photo cloud app) 

At the bottom of the shelf is a printer that still works but is kind of old and in the future will be disassembled for parts to use in my electronic endeavours.

Iron at the office

Hi all. This post shows some pics of my hardware set up for running virtual machines and in the future containers. XekmyPic is deployed to these machines. I keep the VM’s configured through puppet, the code up to date with Git, and monitoring them with zabbix.
I know these machines are kind of old by now but I hope to run them until they fail on their own. Which I hope it won’t be anytime soon. The one on the left is a 3.1 model from 2008 and still runs flawlessly. Only problem is that I can’t update the OS anymore. It has been discontinued. But for serving webpages (this blog) its fine.

Photo cloud app coming along

I have a pet project that I’ve been working on in my spare time. It’s a cloud based photo storing and sharing app. The server side is python   and the client side is for now just cocoa. I had this client done in Objective C and am re-doing it in swift 3. I am also about to try some big data technologies like Hadoop and Cassandra to build the analytics and social media aspects of the app. For that I need to read some books first 🙂

Below is a screen shot of the browse photo’s UI on the client app.

Fooling around the kit

A few months ago I purchased a top of the line e-drum kit from roland. A TD50-KV model, the state of the art. Been fooling around with it since. Still learning the basics such as stick control exercises and playing with a metronome to learn how to keep time when playing. Doing the exercises is kind of boring, but when it comes to drumming from what I’ve read, they are a must do develop muscle memory and coordination. Below is another pic of the kit.
 Because time is not abundant, I am also trying to play basic rock beats that are fun to do, and make practice time less boring.