Community site: login faq

I'm new with Webfaction and I know from experience that I'll need a reverse proxy to cache my site.

Is there a preferred reverse proxy cache solution to use with Webfaction?

My app with be a straight Static/CGI/PHP app. I searched the docs and the forum and didn't find anything appropriate.

asked 24 Sep '11, 08:45

accept rate: 0%

Please check our documentation on serving static media: http://docs.webfaction.com/software/static.html#serving-static-media

Making a "Static only" app will ensure that the files are served via the frontend Nginx server and are not forwarded to the backend Apache server.

If this is not what you had in mind, please elaborate. Are perhaps you trying to set up the static portion of your site to run through a third-party CDN?

(24 Sep '11, 09:21) todork

Thanks for the reply.

What I want to do is cache dynamic pages for 10 minutes so that they aren't being regenerated constantly. I believe that a caching reverse proxy is the tool for this job, would you/anyone concur?

(24 Sep '11, 11:46) carbonsink

Yes, it sounds to me like you'll need a reverse proxy like Varnish or Squid.

You should be able to build either of those from source and run it as a custom application - but we don't have a way for you to use them to cache a site served by our shared Apache instance (ie the Apache that serves Static/CGI/PHP applications.

To work around that, you can build your own Apache+PHP stack from source and use that to serve your sites along with your caching proxy.

Beyond that, we don't have any step-by-step instructions, mainly because nobody's really raised this issue before. Feel free to ask any questions if you run into problems as you set things up.

permanent link

answered 24 Sep '11, 13:09

accept rate: 37%

edited 24 Sep '11, 13:12

Thanks Sean. It seems that I also need a custom Apache+PHP stack in order to use memcached with PHP: http://community.webfaction.com/questions/1842/memcached-and-php

But if I go that route I lose the nice WebFaction control panel app to create apps/sites, right? And I've got to build my own cron-based restart script to ensure my custom app will restart automatically if it goes down, right?

Caching is important to keep the load on the servers reasonable but WebFaction doesn't provide any of the tools to do that, at least not with a Static/CGI/PHP site.

(24 Sep '11, 18:59) carbonsink

But if I go that route I lose the nice WebFaction control panel app to create apps/sites, right?

No and yes :)

You can still create apps via the control panel, and you can still create sites via the control panel, but you also need to do a bit of extra work to configure your private Apache to serve your sites. The general steps are:

  1. Create a new app.
  2. Create a VirtualHost in your httpd.conf to serve the new app on whatever domain and path.
  3. Create a new site to serve your private Apache on whatever domain.

Once that's done, requests for the domain will go to your Apache, which will then serve whatever app based on the VirtualHost you created.

And I've got to build my own cron-based restart script to ensure my custom app will restart automatically if it goes down, right?

Yes, but that's pretty easy. Here, take mine:

*/20 * * * * ~/webapps/phpstack/bin/apachectl start > /dev/null 2>&1

Hope that helps!

(24 Sep '11, 19:07) seanf

Almost there. Here's the part I don't completely understand: I have a private Apache successfully listening on localhost at the randomly assigned port but how will I get the reverse proxy to listen on port 80 without conflicting with other users?

(24 Sep '11, 20:40) carbonsink

You can not get your reverse proxy to listen at the port 80 as our frontend server runs on that server but instead you can setup a custom app(running on port) for it and run the app on the assigned port.

You should then mount that app on your site instead of the phpstack and point to the stack app internally in your reverse proxy's configuration.

(24 Sep '11, 21:06) neeravk

"You should then mount that app on your site" - yes, thanks, but how does one mount an app that's running on a port other than 80?

Specifically, its running at

(24 Sep '11, 22:58) carbonsink

You can just add it to your site record at the URL path /.

The control panel will automatically configure the frontend server to proxy to the correct port.

(24 Sep '11, 23:01) neeravk

Got it now. The phpstack shows up automagically in the app list then I link a website to it.

Thanks much for your help.

(24 Sep '11, 23:04) carbonsink
showing 5 of 7 show 2 more comments

Just to document the gotcha that got me...

I chose to install Varnish, from source, and chose to use their compile method which differed slightly from WebFaction's instructions:

./configure --prefix=$HOME
make install

The 'make' line caused unrecoverable errors with 'libtool'. Eventually this is what solved it: not using the Varnish supplied libtool but using the one already installed on the machine:

cd ~/varnish-3.0.1
mv ./libtool ./libtool_old
ln -s /usr/bin/libtool ./libtool
make install

I now have Varnish installed as a custom app on an assigned localhost port accepting requests from WebFaction's nginx and passing those requests to phpstack (custom installed Apache/PHP) on a different assigned localhost port.

I hope this info helps someone else.

permanent link

answered 26 Sep '11, 19:18

accept rate: 0%

Thanks for the tip! I was having the same error and this solved it.

(17 Jan '12, 07:21) robflaherty
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 24 Sep '11, 08:45

question was seen: 9,333 times

last updated: 17 Jan '12, 07:21