Apache2 configuration for Rails

I recently had to stand up a Rails production server that used Apache2 as a reverse proxy. While it was relatively easy proxying requests to the Thin server using ProxyPass, assets would not show up, even with a DocumentRoot specified. It seems that ProxyPass proxies all requests, and the configuration needs to specifically ignore proxying certain requests using the exclamation mark syntax. The configuration looked like:

ServerName example.com
DocumentRoot /var/www/app/public
ProxyPassMatch ^/(assets/|(404|422|500)\.html|favicon\.ico|robots\.txt) !
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *