Using the right tool for the job…

I encountered an interesting problem after setting up load balancing for a web service one of our devs needed to make available: Accessing a dummy page with a HTTP GET went flawlessly when using a regular web browser, but POSTing to it using his client software or curl resulted in a 503 error. At first I suspected a misconfigured firewall, but when reading the HAProxy logs, I discovered that the 503 error was accompanied by a “<NOSRV>” tag, meaning that HAProxy couldn’t make out to which backend it should forward the client data.

The solution was simple: Up until now, I’d only forwarded traffic from modern web browsers, using the ssl_fc_sni function to find the appropriate backend based on the server name requested by the client. What I forgot when setting up these rules was that the POST wouldn’t be performed by a modern browser, so I had no guarantee that the client would be capable of the SNI (Server Name Indication) protocol extension.

The simple solution was to use the host record from the HTTP header instead:

use_backend backend1 if { hdr(Host) -i service.domain.com }

Note that this requires that SSL is terminated in HAProxy. My configuration terminates SSL, reads and modifies relevant HTTP information, then establishes a new SSL connection to the backend servers using the appropriate certificate checks. This way protocol secrecy should be kept anytime traffic is in transit.

Advertisements

Apple Smart Keyboard First Impressions

Having just received my Smart Keyboard for my iPad Pro 9,7″, I thought I’d write a little about it.

The first thing I was slightly apprehensive about was naturally how it would feel to type on it. The Apple tables in stores don’t really lend themselves to actually testing that aspect realistically. It turns out I worried unnecessarily: The cupped shape of the keys, along with the relatively large gap between them makes it very comfortable for me to type on the keyboard. Going from my Retina MacBook Pro or Magic Keyboard to the Smart Keyboard is almost completely seamless for me. It’s comfortable enough on a table, but what’s interesting is that thanks to its strong magnets, it actually works in my lap while half-lying in a couch too. At least as long as the iPad itself keeps its center of balance towards the rear support.

The keyboard itself supports almost all shortcuts and key combinations I’m used to from Apple’s computer keyboards except for those that require the use of the Fn key, which on the Smart Keyboard is replaced by a shortcut to switch between keyboard layouts.

As I am used to writing on a Swedish keyboard but often write technical documents in English, I soon encountered a situation that could have turned the Smart Keyboard into a dud for me:
How does it handle typing in one language while using the keyboard layout of another language? The autocorrect dictionary in iOS is tied to the chosen keyboard layout. Turns out Apple thought of that issue long before I did. When I did, I was very happy to see that under General Settings, there’s a button called Hardware keyboard. Thanks to it, it’s possible to turn off text autocorrection while using a physical keyboard while retaining the function when typing on-screen, where special characters are chosen visually anyway. This is one of those small things that makes me fond of Apple. This need of mine probably represents a pretty small percentage of Apple’s customers, but one of their developers thought of it and implemented a solution that makes switching from tablet mode to “almost laptop” mode completely seamless.

So are there any drawbacks to the Smart Keyboard?
Not a lot of them. One thing I noticed quickly is that the edit field on some forums doesn’t capture the cursor keys: Marking text using various combinations of Shift, Option, Command and the cursor keys is somewhat hit-or-miss across different sites on the web. In WordPress it works perfectly, but on the MacRumors forums touching any of the cursor keys while in the edit field scrolls to the bottom of the page. At this point I have no idea where the problem lies, but it’s a bit frustrating since selecting text is a chore using fingers on a touch screen.

All in all, and in my use case, the Smart Keyboard complements the iPad Pro perfectly, and I can definitely see myself leaving for an extended vacation without bringing my computer along largely thanks to it. Time will tell whether I’ll stay happy with this combination or if I’ll rather invest in an ultralight laptop the next time I have to replace my hardware.