I know, it’s been a long time since my last post. At Squad, we’ve added the ability to have our own little devblogs, but I’ve found that vB4’s CMS just isn’t adequate for some things, and it’s difficult to write tutorials meant for professionals or hobbyists without spamming the devblogs with irrelevant things. So, I’m going to start using this dusty old thing.
So, you’re probably here from a search, trying to figure out how the hell to get your Varnish 3.x server to reverse-cache vBulletin 4, all without too much removal of your hair or sanity, and without paying through the nose for a cPanel plugin that won’t even work for your situation. Well, you’re in luck.
We had the same problem at Squad: We have a forum with millions of users that does terrible things to MySQL when under load, and we thought Varnish would help. It does, but there’s a crucial lack of documentation for getting it to play nicely with popular software, such as Varnish. After hundreds of fruitless Google Searches, we eventually gave up: All the instructions out there are either horrifically old, horrifically expensive, or assume you’re using Apache. We use Lighttpd, so all those options were immediately out the window.
So, here’s what we eventually settled on. This tutorial assumes you have a working vB4, MySQL, and HTTP daemon.
- Install Varnish on your OS. We use CentOS, so we added their repository to yum as their instructions recommend.
- Edit /etc/sysconfig/varnish and set up Varnish to use port 80 and leave the ADDRESS section blank. (May be /etc/defaults/varnish on Debian or Ubuntu.) Tune the other settings as needed.
- Edit /etc/varnish/default.vcl and replace everything with this. Replace “bb” in the cookies with whatever your cookie prefix is. Original skeleton of this was from VeggieMeat on github, but it needed serious updating.
- Edit includes/config.php and uncomment or add the following (this is something I haven’t seen referenced much):
/* Enter your known [trusted] proxy servers here. You can list multiple trusted IPs separated by a comma.*/ $config['Misc']['proxyiplist'] = '127.0.0.1'; /* If the real IP is passed in a http header variable other than HTTP_X_FORWARDED_FOR, then you can set the name here; */ $config['Misc']['proxyipheader'] = 'HTTP_X_FORWARDED_FOR';
- Set lighttpd to use port 8080 (or whatever you configured it to in default.vcl).
Now, all you need to do is run
service lighttpd stop && service varnish start && service lighttpd start!