selective proxy port forwarding on Apache httpd

淺唱寂寞╮ 提交于 2019-12-22 11:02:20

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/18561049/selective-proxy-port-forwarding-on-apache-httpd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!