Figured it out after a bit of trial and error. Here's what I have...
Can I achieve this on one server using one IP address or do one server to host and one to mod_proxy with?
A: ON server with one IP address works just fine. All proxy functions are handled via a port which in my case is :9000. The choice of port number is really up to you. 9000 was just a high number and didn't conflict with any other node functions. It also seems to be a unwritten standard from what I can tell.
If I can do this on one server. If so, what is the generic setup (A to B)? One or two virtual hosts?
A: This is probably best explained by just looking at my Apache virtual host setup...
Since i'm using SSL, all port :80 HTTP requests are rewritten to HTTPS
VirtualHost *:80
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) http(s)://%{HTTP_HOST}%{REQUEST_URI}
/VirtualHost
I'm running a node app on port :3000 so all traffic is routed from the standard :443 to port :3000 and visa versa. Basically port :3000 becomes the primary domain name via a server proxy as far as the public is concerned.
VirtualHost *:443
RewriteEngine On
ProxyRequests Off
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /pathToCert/sslCert.crt
SSLCertificateKeyFile /pathToKey/sslKey.key
Location /
ProxyPass http://localhost:3000/
ProxyPassReverse http://localhost:3000/
/Location
/VirtualHost
I've assigned port :9000 as the reverse proxy for my Cross Domain HTTP POST requests. The ProxyPass and ProxyPassReverse directives essentially rewrite the url of HTTP requests I make with an address of my domain.
https://MySite.com:9000/?request¶ms&here
will become
https://SomeOtherSiteThanMine.com/?request¶ms&here
Thus fooling the browser into thinking I'm making requests to my own domain. Also notice the "Header set" lines which make the requests CORS compatible with my proxy.
VirtualHost *:9000
RewriteEngine On
ProxyRequests Off
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /pathToCert/sslCert.crt
SSLCertificateKeyFile /pathToKey/sslKey.key
ProxyPass / https://SomeOtherSiteThanMine.com/
ProxyPassReverse / https://SomeOtherSiteThanMine.com/
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "POST"
/VirtualHost
3. Explain the ProxyPass and ProxyReversePass directives. Do I need to add my outside service URL here?
A: See above
4. Am I just going the complete wrong way down a one way street?
A: Nope, ended up working out perfectly.
If anyone sees a problem with the method, by all means chime in. I just pieced together a a handful of vaguely described examples.