Use NodejS API with Apache

80 views Asked by At

I have a dedicated server to host my webapps.

I created a NodeJS app :

var http = require('http');
http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Hello World! Node.js is working correctly.\n');
}).listen(8080);
console.log('Server running at http://127.0.0.1:8080/');

Then i created a virtualhost for Apache2 :

<VirtualHost *:80>
    ServerName myServer.name
    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
</VirtualHost>

This command line : curl myServer.name return Hello World! Node.js is working correctly.

But in browser it does not work at all. (Connection refused)

What i missed ? Don't understand why it works on curl (and postman) but in browser ...

Thanks

[UPDATE] : Ping work only on my host machine (by ssh) Why ?!

0

There are 0 answers