Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selective proxy port forwarding on Apache httpd

I am trying to integrate wordpress into my site which is running on Nodejs server with Apache Httpd port forwarding enabled to forward all the request from 80 port to Nodejs port 9000. I have installed wordpress into Apache httpd /www/blog folder.

Now, i want to edit my httpd.conf so that all my requests coming from client should still be forwarded to nodejs server except my blog.example.com calls which should not be proxy forwarded and they should point to /www/blog folder. Is this possible ?

Here is the Virtualhost code from httpd.conf :-

    <VirtualHost *:80>
        ProxyPreserveHost On
        ProxyPass / http://localhost:9000/
        ProxyPassReverse / http://localhost:9000/
        ServerName example.com
    </VirtualHost>

Any help would be appreciated.

like image 534
Gaurav Avatar asked Apr 18 '26 12:04

Gaurav


1 Answers

This worked for me. Might be of some help for others.

    <VirtualHost *:80>
         RewriteEngine on
         RewriteCond %{HTTP_HOST} ^blog\.example\.com
         RewriteRule ^(.*)$ http://www\.example\.com/blog/$1 [L]

         ProxyPreserveHost On
         ProxyPass /blog !
         ProxyPass / http://localhost:9000/
         ProxyPassReverse / http://localhost:9000/
         ServerName example.com
    </VirtualHost>
like image 164
Gaurav Avatar answered Apr 21 '26 05:04

Gaurav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!