Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Running Pow with Apache

Jerimiah Milton edited this page Jul 17, 2017 · 24 revisions

If you want to run pow alongside the MacOS X built-in apache this page will instruct you on how to setup pow so that it doesn't takeover port 80 and instead apache will reverse proxy requests to pow.

For the Impatient

$ curl get.pow.cx/uninstall.sh | sh #if you have pow installed
$ echo 'export POW_DST_PORT=88' >> ~/.powconfig; source ~/.powconfig
$ sudo curl -L https://gist.githubusercontent.com/soupmatt/1058580/raw/zzz_pow.conf -o /private/etc/apache2/other/zzz_pow.conf
$ sudo apachectl restart
$ curl get.pow.cx | sh

Full Installation Instructions

1. Before installing

Before you install pow, add the following line to your ~/.powconfig

export POW_DST_PORT=88

Here it is as a one-liner

$ echo 'export POW_DST_PORT=88' >> ~/.powconfig; source ~/.powconfig

This will cause pow's firewall run to redirect all traffic from port 88 instead of port 80. You can pick any port you like for this if you use 88 for something else. It doesn't affect the remainder of these instructions. If you have already installed pow, you will need to uninstall it before you you continue.

2. Install pow as normal

If you need those instructions, you can find them here: Installation

3. Configure Apache

You'll need to drop the file in this gist into

/etc/apache2/other/zzz_pow.conf

Here it is as a one-liner

$ sudo curl https://gist.githubusercontent.com/soupmatt/1058580/raw/zzz_pow.conf -o /etc/apache2/other/zzz_pow.conf

This sets up apache to act as a reverse proxy to pow. It goes directly at pow's default listen port, not the firewall port we configured in the previous step. The file name zzz_pow.conf to ensure that apache picks up the vhost for pow last, allowing you to put vhosts for other apps in front of it.

Running XCode CI bots?

Use this config instead if you need Pow and Xcode CI on the same box: https://gist.github.com/qrush/84829fd3abe149559de0

4. Start/Restart Apache

You'll need to turn on "Websharing Sharing" in the MacOS X system preferences if you haven't already. You can find it in System Preferences -> Sharing -> Web Sharing. NOTE: This will make it so anyone with your machines IP Address can access your apache server. This is the default setting from apple. If you want to change this, you will want to change the IP address that apache binds to in /etc/apache2/httpd.conf.

If Apache is already running, you can restart by either turning Web Sharing off and then back on, or you use this on the command line

$ sudo apachectl restart

After Installation

Leveraging pow's DNS for other apps

If you now configure your vhosts for the apps you want to run in apache with *.dev hostnames, pow will provide the DNS resolution for you, which means you get to keep the benefit of not mucking with your hosts file. For example, if you have a php app, you can setup its vhost entry to use my_php_app.dev and you don't need to add that to your hosts file.

Using ssl with pow

This setup can be extended to allow using ssl with pow. To do this, you need to configure the pow vhost we setup for apache for ssl by following the apache documentation. The implementation is left as and exercise for the reader, and is restricted by the normal limitations of using ssl with apache and a name-based vhost configuration.

Troubleshooting

Apache is servicing a request that I expect to be passed to pow

Make sure that you don't have another virtual host that is configured with the same name

Pow is servicing a request that I expect to be passed to Apache

Make sure that you have another (default) virtual host configured. For example, something like this:

/etc/apache2/other/aaa_default.conf

<VirtualHost *:80>
  #no need for settings, use apache defaults.
</VirtualHost>

You also need to ensure VirtualHost's are enabled, that is this line needs to be in your config somewhere

NameVirtualHost *:80

You could put it into your httpd.conf or uncomment the vhosts extra line in it:

Include /private/etc/apache2/extra/httpd-vhosts.conf

I suggest you comment out the sample vhosts specified in that file.

I still get a 404 error in Apache after doing all this

Please make sure that in your httpd.conf you include your vhosts and other config files in the right order.

Include /private/etc/apache2/extra/httpd-vhosts.conf
Include /private/etc/apache2/other/*.conf

!!! Couldn't resolve configured domains (local,dev)

See: https://github.com/37signals/pow/issues/172#issuecomment-4610594