I have nodejs, php and apache2 running on ubuntu 14.04.
There are nodejs listening on different ports (eg. 3000, 3001...).
So, I want to setup virtual host, so that when user requests the nodejs service, the user can go "http://nodejs.example.com/api" instead of "http://example.com:3001/api" And at the same time, I want to maintain all post/get data being sent.
following is my virtual host configuration:
#/etc/apache2/sites-available/mySite.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example
ServerAlias nodejs.example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location />
ProxyPass http://127.0.0.1:3001/
ProxyPassReverse http://127.0.0.1:3001/
RewriteEngine On
RewriteRule http://nodejs.example.com:3001/$1 [R=301,L]
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Can anyone please help?