Tag Archives: apache

Ubuntu forward proxy with mod_proxy

  1. apt-get install libapache2-mod-proxy-html
  2. a2enmod proxy_html
  3. cp /etc/apache2/sites-available/default /etc/apache2/sites-available/proxy
  4. put in a custom port, and the following:

    ProxyRequests On
    ProxyVia On

    Order deny,allow
    Deny from all
    Allow from [hostname or IP]

  5. put the following at the bottom of ports.conf:

    Listen [your port]
  6. create some symlinks:
    cd /etc/apache2/mods-enabled/
    ln -s ../mods-available/proxy.load
    ln -s ../mods-available/proxy_http.load
  7. restart apache
    service apache2 restart
  8. you should now be able to use the proxy server

Pool memory errors in apache

I was getting this error a lot on a Drupal site:

Warning: include(): Unable to allocate memory for pool.

Turns out it’s not the apache or php settings, but APC (pecl module).

To fix, add the following to your php.ini file:

apc.shm_size = 64 (adjust value to your server capabilities)


Using strace to analyze apache

For times that you want to know exactly what a process is doing (for instance, if your apache is Pleskified and you’re getting weird website errors that can’t be traced back to any of your own code…) you can use strace.

 service apache2 stop

strace -f -o trace.txt /etc/init.d/apache2 start  # this will run strace on all child processes of apache, so you don't need to worry about figuring out the correct process

## do whatever to generate the error message (in my case, just accessing the site)

service apache2 stop

## use htop to verify the strace has stopped

service apache2 start

Then check trace.txt to find your issue!

And have a look here for a more thorough tutorial.

Getting default site in Apache2 to display a 404

Rather than showing the alphabetically first virtualhost (alphabetically based on file name, if you have one file for each virtualhost, otherwise it will show whatever’s at the top of your single virtualhost file).

<VirtualHost *:80>
    Redirect 404 /.*

I’m getting some errors when trying to do the same with SSL sites, out of time now but will try and sort another day.