I'm working on a project where website content is based on PHP(CodeIgniter) behind Apache server, and my duty is to write a node.js as an API to upcoming mobile version of the app. (Note, our hosting is managed, we do not have access to virtualhost so using proxypass is out of reach)
I have to make my node file run behind Apache, in a URL like "domainname/api". When said URL is called, Apache has to bridge this request to localhost:port, where node is living on.
Here is my node.js file:
var fs = require('fs');
var http = require('http');
var app = require('express')();
var options = {
};
app.get('/', function (req, res) {
res.send('Hello World!');
});
http.createServer( app).listen(61000, function () {
console.log('Started!');
});
Here is my .htaccess file:
RewriteEngine on
RewriteRule ^$ /index.php [L]
RewriteCond %{HTTP_HOST} !^ourdomainname\.com
RewriteRule (.*) http://ourdomainname.com/$1 [R=301,L]
RewriteCond $1 !^(index\.php|info.php|resource|system|user_guide|bootstrap|robots\.txt|favicon\.ico|google<somevalues>.html)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^/api$ http://127.0.0.1:61000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/api/(.*)$ http://127.0.0.1:61000/$1 [P,L]
Although node works locally(on our managed hosting server) (I can call "lynx localhost:61000/" and see proper output), it doesn't work on outside local. All our calls to "ourdomainname.com:61000/api" is sent to CodeIgniter(PHP), not to our node.js file.
Any help is appreciated.