0

I have this in my server.js :

var app = require('express')();
var http = require('http');
http.createServer(function(request, response) {
      response.writeHead(200, {"Content-Type": "text/plain"});
      response.write("It's alive!");
      response.end();
}).listen(3000);

this works fine on local but not when I deploy it and try access to my shared.domain.ma:3000 In the client side I have a Websocket that trying to connect to my server in that address but it give me net::ERR_CONNECTION_TIMED_OUT ann I tried curl and the result is the same again - What could be reason of this problem?

t.niese
  • 39,256
  • 9
  • 74
  • 101
Siempay
  • 876
  • 1
  • 11
  • 32

2 Answers2

0

You provided very little info but after some of your comments it is more clear:

yes I just checked its the damn firewall .. I cant use 80 or 8080 cuz they are allready used ! How can I forward 3000 to 80 for just this subdomain

I think you want to forward 80 to 3000, not the other way around.

You didn't say what server do you use for a reverse proxy. If it is nginx then you can use something like this:

server {
    listen 80;
    server_name www.example.com;
    location / {
        proxy_pass http://localhost:3000;
    }
}

See this answer for more details:

Of course you can do the same with Apache, just with different config. Search for reverse proxy config.

Community
  • 1
  • 1
rsp
  • 107,747
  • 29
  • 201
  • 177
0

You are firewalled, as noted in the comments. For nginx, check the other answer. For Apache, use the following configuration, don't forget a2enmod proxy:

#/etc/httpd/conf.d/node.conf
<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerName mydomain
   ServerAlias www.mydomain.com
            
   ProxyRequests Off
   ProxyPreserveHost On
   ProxyVia Full
   <Proxy *>
      Require all granted
   </Proxy>
 
   <Location />
      ProxyPass http://127.0.0.1:3000
      ProxyPassReverse http://127.0.0.1:3000
   </Location>