Skip to content

Apache httpd vhost configuration

shai-weinstein edited this page Aug 12, 2013 · 4 revisions

example of apache httpd vhost configuration. proxying requests to node.js, skipping static content proxying

you need to enable mod_proxy and mod_proxy_http in apache (in ubuntu run: sudo a2enmod proxy proxy_http)

ProxyRequests Off
<VirtualHost *:80>
        ServerName m.yourdomain.org
        <Proxy http://localhost:3000*>
          AddDefaultCharset off
          Order allow,deny
          Allow from all
        </proxy> 
        ProxyPassMatch ^/(lib|js|img|css|views|robots\.txt$|humans\.txt$) !
        ProxyPass / http://localhost:3000
        <Directory />
                Options None
                AllowOverride None
        </directory>
        DocumentRoot /var/www/mean/public
        <Directory /var/www/mean/public>
                Options None
                AllowOverride None
                Order allow,deny
                allow from all
        </directory>
        ErrorLog ${APACHE_LOG_DIR}/m.yourdomain_error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/m.yourdomain_access.log combined
</virtualhost>

can also replace the Proxy directives with something like:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(lib|js|img|css|views|robots\.txt|humans\.txt) [NC]
RewriteRule ^(.*)$ http://localhost:3000$1 [L,P,QSA]

need to enable apache rewrite module for this to work (on ubuntu: sudo a2enmod rewrite)

Clone this wiki locally