Gary Sieling

Apache: forward directory to port

To have Apache proxy requests to node, you need these modules enabled:

a2enmod proxy
a2enmod http_proxy

This is what I ended up with for configuration – note how simple the ProxyPass bit is (you can’t do all this in .htaccess, it’s not worth trying).

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


      ServerAdmin gary.sieling@gmail.com
      ServerName garysieling.com
      ServerAlias www.garysieling.com
      DocumentRoot /srv/www/garysieling.com/public_html/
      ErrorLog /var/log/apache2/garysieling-error.log
      CustomLog /var/log/apache2/garysieling-access.log combined

      ProxyRequests Off
      ProxyErrorOverride Off

      
        ProxyPass "http://127.0.0.1:3000/search"
      

      ProxyPassReverse "/search" "http://localhost:3000/search"

The most difficult part of this entire thing is to get slashes correct in the paths.

You really need logging set up on node, if you have problems.

Exit mobile version