nginx/php single config for SSL and non-SSL connection

This morning I noticed I haven’t upgraded WordPress MU Domain Mapping plugin to the latest version. It supposedly brings better SSL support. And after upgrading I couldn’t log in to my mapped domain blogs (e.g. this blog). Wasn’t it a great way to start my morning?

After some digging, I found out the problem was because I don’t have one PHP(?) parameter – HTTPS – passed properly. It should set to True whenever one is using SSL connection otherwise there’s no way the PHP process can know if the connection is secure or not. Previous version of WPMUDM have a bug in which skips SSL check but in turn enables using HTTPS even without such parameter. Decided it’s my fault (I believe it would completely breaks phpMyAdmin), adding the parameter then I did.

But it’s not that simple: I’m using unified config for both my SSL and non-SSL connection’s PHP include. Splitting the config would make the duplication worse (it’s already relatively bad as it is) so that’s not an option. Using the evil if is also not a solution since it doesn’t support setting fastcgi_param inside it.

Then the solution hit me. The map module – a module specifically made for things like this and to avoid usage of if. I tested it and indeed worked as expected.

Here be the config:

...
http {
  ...
  map $scheme $fastcgi_https {
    https 1;
    default 0;
  }
  ...
  server {
    ...
    location ~ \.php$ {
      ...
      fastcgi_param HTTPS $fastcgi_https;
    }
...

And WordPress MU Domain Mapping is now happy.

Ore no Kanojo to Osananajimi ga Shuraba Sugiru chapter 8

Hello there. This manga has fucking long title. And the scanlator decided to skip on giving DDL after their previous attempts in using watermark. Inb4 they reinvent SecuROM.

Ripped from batoto with following command:

for i in {1..37}; do
 curl -O "$(curl http://www.batoto.net/read/_/76060/ore-no-kanojo-to-osananajimi-ga-shuraba-sugiru_ch8_by_japanzai/$i \
 | grep 'img src="http://img.batoto.com/comics/' \
 | sed -E 's/.*src="([^"]+)".*/\1/')"
done

Whoopsie, as it turns out, the files are actually gif. Brb fixing them.

Here be fix:

for i in *.png; do mv $i ${i%%.*}.gif; done
for i in *.gif; do convert $i -flatten ${i%%.*}.png; rm $i; done

Links updated to fixed pack.

[ Fileserve | myconan.net ]

This pile of crap called OpenLDAP

In attempt to learn THE directory service called LDAP, I tried to setup OpenLDAP in Scientific Linux. The install went all right and slapd can be immediately started without much problem. Except that the config is one big mystery and there’s not even a rootpw defined by default. Being a complete newbie in LDAP thingy, I decided to build configuration and all from zero.

…except that it’s not actually trivial. Most examples/tutorials are for OpenLDAP prior to 2.4 which still uses slapd.conf which was obsoleted in favor of configuration in meta-format using LDAP’s ldif. Instead of one nice config, instead we have directories called cn=config etc inside slapd.d. Someone must’ve been into Linux too much (xxx.d – Linux users sure love “modularizing” their configs).

Anyway, the example in manual page of slapd-config doesn’t even work because the include syntax was wrong (should be file:///etc/… instead of /etc/…) and even after fixing that there still an error:

[root@charlotte openldap]# slapadd -F /etc/openldap/slapd.d -n 0 -l initman.ldif
str2entry: invalid value for attributeType olcSuffix #0 (syntax 1.3.6.1.4.1.1466.115.121.1.12)
slapadd: could not parse entry (line=626)
_#################### 100.00% eta   none elapsed            none fast!
Closing DB...
[root@charlotte openldap]# slaptest
slaptest: bad configuration file!

The example from the guide also gives exact same error.

In short, I kind of given up and tried to follow the “Quick Start” from the very same guide. Instead of using slapd.d format, it still uses slapd.conf format despite it being a guide for 2.4. Seems like following a pattern, the config example also spit out error:

[root@charlotte openldap]# vi slapd.conf
[root@charlotte openldap]# slaptest
/etc/openldap/slapd.conf: line 2:  invalid DN 21 (Invalid syntax)
slaptest: bad configuration file!

So much for an example. Few attempts later at both methods, I gave up and wrote this post.

Compiling PuTTY for Windows

Because of one awesome bug inflicts eye-cancer when using Consolas font and deactivated “Bold text is a different colour”, I had to recompile PuTTY by hand (more like, by gcc). I initially tried to compile the PuTTYTray one but apparently they successfully mixed C and C++ code and completely broke the build procedure using mingw. Or I missed something obvious.

Anyway, I went back to vanilla PuTTY. As it turns out, compiling using latest mingw’s gcc isn’t a good idea since it removed -mno-cygwin option and therefore broken unless you do some magic edit. Thanks to that, I stopped bothering trying to compile it under Windows and used mingw-gcc for Linux (which is able to produce Windows binary). Here be the steps from beginning. Tested on Debian 6.

apt-get install mingw32 subversion perl
svn co svn://svn.tartarus.org/sgt/putty putty
cd putty
perl mkfiles.pl
cd windows
make VER="-DSNAPSHOT=$(date '+%Y-%m-%d') -DSVN_REV=$(svnversion) -DMODIFIED" TOOLPATH=i586-mingw32msvc- -f Makefile.cyg putty.exe

Patch is done before make (duh) and the diff can be found here. If you’re lazy (like me) you can just download the build at my server (link at bottom). Should be virus-free but I guess you can notify me if you encounter one. Built everyday until it breaks.

  • exe: the program
  • sha512: hash of the program
  • zip: both program and its checksum

[ exe | sha512 | zip ]

Love, Election, and Chocolate gets anime adaptation

Koi to senkyo to chocolate, an eroge from sprite just announced to get anime adaptation.

From ANN:

The January issue of ASCII Media Works’ Dengeki G’s Magazine is announcing a 2012 television anime adaptation of sprite/fairys’ Love, Election, & Chocolate (Koi to Senkyo to Chocolate) adult game on Wednesday. The 2010 Windows game follows the protagonist at a “mega academy” with over 6,000 students. To save his cooking club from being abolished, the protagonist agrees to run for student body president.

The art was good and as usual I have no idea what the story is about :D

And again, as usual, I need to prepare for art quality degradation compared to original art. At least I’m not a big fan of Akinashi Yuu (and Koichoco being the only eroge art he/she ever done) though it’ll still be sad seeing it degrades.

No information on animation studio or pretty much everything else.

Hitsugi no Chaika chapter 1

Here be fileserve link to Hitsugi no Chaika chapter 1 which seems to be recommended by Kurogane.

Here’s the bash command I used to leech from this batoto.com thingy. Originally one-liner but reformatted for readability:

for i in {1..66}; do
  curl -O "$(curl http://www.batoto.net/read/_/52737/hitsugime-no-chaika_ch1_by_village-idiot/$i \
    | grep 'img src="http://img.batoto.com/comics/' \
    | sed -E 's/.*src="([^"]+)".*/\1/')"
done

Yes, I parsed html using sed/regex :D

Flame away.

PS: Apparently I fail at leeching shit. Should’ve checked file formats before deciding it’s jpg. Just extract the files and rename the files with correct extension if you’re feeling dilligent (or getting broken image with MMCE). Only page 1-4 are jpg.

PS: whatever. Fixed everything. Added ddl from my own site since I want to waste some bandwidth.

[ Fileserve | myconan.net ]