Proxying from Apache HTTPS to some backend server that only speaks HTTP

Here’s a use case: You want to run an application server that only speaks HTTP, but securely, over HTTPS. The problem is that the application server won’t know that it’s being accessed via HTTPS, so any URLs and redirects it generates might point to HTTP. Here’s an example virtual host entry that takes care of that by rewriting the header. You need Apache, mod_proxy and mod_headers. <VirtualHost *:443> ServerName foo.bar.example.com SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key Header edit Location "^http:(.*)$" "https:$1" PassengerEnabled off ProxyPass / http://127.0.0.1:3000/ ProxyPassReverse / http://127.0.0.1:3000/ DocumentRoot /var/www/foo/bar <Directory /var/www/foo/bar> AllowOverride none Options -MultiViews </Directory> </VirtualHost> The magical line is the one with “Header edit…”. This makes sure any request your app server would have sent to HTTP are rewritten to HTTPS. ...

March 13, 2013 · Psy-Q

The slow and painful act of ungoogling yourself

With Google’s questionable treatment of privacy, you might want to gain some distance from that company. I’ve done that myself a couple of steps at a time, and now I’m at the point where only one or two unhappy circumstances keep me nailed to the crucifix of Google systems and services. Here’s what worked well: Replacing Google Reader with my own TinyTinyRSS instance. Replacing Picasa with my own Gallery instance. Replacing Gmail with my own Postfix and Courier servers. I use a fucking awesome email client and organize my stuff well, so I never need to rely on Gmail search anyhow. ...

January 7, 2013 · Psy-Q

Creating your own Steam Cloud (or how to reliably sync any two directories)

I was quite annoyed that the Steam Cloud seems to misread file timestamps some of the time, resulting in game saves being overwritten with older versions. And since Steam doesn’t offer a way to reliably find out which save is the most recent one, I needed something better. The things I need: Connects over SSH, works with an SFTP/SSH server Transmits only file differences Reliably determines which copy of the pair is the newest Takes any required actions to make the older copy be identical to the newer one Works on GNU/Linux and Windows, since some games still aren’t available on Linux Should be able to save sets of pre-defined sources and targets so I can sync with one click or command If you have similar needs, I might have a recommendation for you: Unison. Unison is not new, but directory synchronization (especially cross-platform) is not a trivial problem, and Unison has had a solution since 1998 and has only improved since then. ...

November 2, 2012 · Psy-Q

Building your own Sublime out of free components with vim

I recently discovered Sublime Text and bought a license even though I rarely use proprietary software for work. That’s how good it felt to me. But if you’re comfortable with an editor like vim, you can make vim feel almost like Sublime, using only free and open source software (FOSS). vim (and emacs) have had many of the features that Sublime has, in some cases for decades. Here’s a very small and simple guide for making vim look and behave a little like Sublime. ...

July 19, 2012 · Psy-Q

Super-legible Heiti-style Chinese font for Debian GNU/Linux

I’m struggling with those crazy Chinese fonts in Mingti and Kaiti style and couldn’t find a goot Heiti font, but now this page: http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux Mentions that there is a perfectly fine Heiti-style font available in Debian: ttf-wqy-zenhei. So do this and be happy: apt-get install ttf-wqy-zenhei Here’s a sort of preview from Wikipedia’s multilingual support page: The samples above are in Heiti, the ones below in Mingti. Putting it into a screenshot makes it look shitty, so you’ll have to install the font (don’t install any other Chinese fonts!) and look at the page zoomed in to see it really well. ...

May 27, 2012 · Psy-Q

Avoding "Invalid byte sequence in UTF-8" with Ruby and CSV files

If you’re running into a ton of problems reading e.g. an ISO-8859-1 encoded CSV file into your (probably UTF-8) Ruby or Rails application, and if the error you get is “Invalid byte sequence in UTF-8” even though you’re giving CSV.open the correct encoding options, here’s a solution. The example CSV file is a tab-separated, ISO-8859-1 encoded file with CRLF line endings. You’d expect the following to work: CSV.open(@infile, "r:ISO-8859-15:UTF-8", {:col_sep =&gt; "t", :headers =&gt; :first_row}) But it fails mysteriously! Even though the conversion to UTF-8 goes without problems, you get an ArgumentError complaining about some illegal byte sequence. If you analyze deeper, you might find (in this case) a complaint about rn. The solution is very, very non-obvious: You need to specify the row separator in addition to your encodings! ...

September 8, 2011 · Psy-Q

Watch TV on your PC, no ads, no Flash

Roman Haefeli strikes again: Watchteleboy makes it possible to watch dozens of live TV channels using mplayer in your very own machine, without the need for Flash, a web browser or any other such nonsense. Here’s the source code: https://github.com/reduzent/watchteleboy Here are Ubuntu packages he maintains: https://launchpad.net/~reduzierer/+archive/reduzent Caveat: This only works if you’re located in Switzerland or in some other place that Teleboy’s geotargetting likes (such as Italy).

September 7, 2011 · Psy-Q

Moving from Google Reader to Tiny Tiny RSS

In my quest for more freedom from companies that don’t take privacy too seriously (such as Facebook or Google), I found a fantastic FOSS replacement for Google Reader: Tiny Tiny RSS. It does everything important that Google Reader does and even has its own little syncable native Android app called ttrss reader (available through the Google Android Market). The only additional feature I’d appreciate is a Reader Play-style view for very important tasks, such as scrolling through large amounts of animated gifs or lolcats quickly. Tiny Tiny RSS’s code seems to be clean and concise, though, so it might not be that much work to make such a feature if I ever find the time (which won’t happen). ...

November 10, 2010 · Psy-Q

Why is Switzerland/Norway so rich/expensive/not part of the EU?

This is a great Google Suggest Venn diagram generator: http://www.technomancy.org/google-suggest-venn. Only a fool would suggest that not being part of the EU makes a country rich and expensive 😛

October 27, 2010 · Psy-Q

Good quality music from your PC, Mac or NAS: Music Streamer

Most PCs come with onboard audio circuits that, at best, sound OK. But there’s a cheap way out of that. The Music Streamer by High Resolution Technologies. It’s an external USB sound interface with a very good D/A converter. This is a semi-audiophile device, yet it costs only about the same as your average USB audio interface these days. This isn’t made for 5.1 surround sound, it only has two analog RCA (Cinch) outputs to hook up to your amp. Of course you can also play games in stereo on it and watch films. Both sounds crystal clear. ...

August 16, 2010 · Psy-Q