-1

I have a server with Parallels Plesk as Server Control Panel, apache2 (with mod_proxy and mod_http_proxy), nginx and Node.js installed. On this server I have multiple domains and subdomains, but only one IP.

If I start a node-app on e.g. port 1337 it will be global accessible on all domains and subdomains on this server/IP with this port. (domainA.com:1337, sub.domainA.com:1337, domainB:1337)

Via Plesk I can change the apache2 vhost.conf for domainA.com. I can use following code to route port 80 to port 1337 for domainA.com: (I'd rather use nginx but the settings in Plesk to adjust nginx quick are somehow limited)

ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass / http://localhost:1337/
ProxyPassReverse / http://localhost:1337/
<Location />
    Order allow,deny
    Allow from all
</Location>

Yaay, I can access my node-app running on Port 1337 through Port 80 on domainA.com!

BUT: Port 1337 is still directly accessible on all domains on my Server. Not only domainA.com:1337 shows me my node-app, sub.domainA.com:1337 and domainB.com:1337 will show my app, too.

It's total logical why this port is still accessible everywhere, but how can I "block" this port on these other domains?

Best case scenario would be that domainA.com:1337 redirects to domainA.com and sub.domainA.com:1337 / domainB.com:1337 won't show anything.

Is this somehow possible with my setup?

If it's possible with nginx instead of apache – why not! I only used apache's mod_proxy because it was way easier to setup in Plesk.

Vasili Syrakis
  • 4,558
  • 3
  • 22
  • 30
  • The simplest way is to make your node app listen only to localhost so it will not be reachable from outside the box. – Alexey Ten Jul 04 '14 at 06:35
  • Thanks, but the app listens only to localhost. If it could only listen to a virtual host, would this be possible or rather is this possible? – Timo Mämecke Jul 04 '14 at 08:24
  • I don't get the question – Alexey Ten Jul 04 '14 at 08:46
  • The Node App is listening only to localhost, that's the default behaviour. My thoughts were: If it could listen to a host other than localhost and the domain (the domain I want to run the app on) will resolve to this host it could work in theory. I don't know if this is actually possible to do. I'm not searching for a complex solution to go through one time – I'm trying to find a simple and easy-to-set-up way for every node app I deploy on my Server. My setup isn't that special. An easy solution would be a benefit for a lot of people. – Timo Mämecke Jul 04 '14 at 09:37
  • If by default you mean `.listen(1337)` you're wrong. «If the hostname is omitted, the server will accept connections directed to any IPv4 address (INADDR_ANY).» – Alexey Ten Jul 04 '14 at 10:04
  • All `hostname` in `.listen()` does is resolving the hostname to a IP address. Since I have only one IP Address (as I wrote) this won't help. – Timo Mämecke Jul 04 '14 at 10:24
  • You have at least two addresses. One external like `1.2.3.4`, and one local `127.0.0.1`. Second address is not reachable from outside the same machine. So `.listen(1337, '127.0.0.1')` will make node unreacheble from other machines, but Apache will still have access via localhost:1337 – Alexey Ten Jul 04 '14 at 10:35
  • That totally works, thanks! Sorry – I thought if something runs on localhost it's accessible from the external IP, too. – Timo Mämecke Jul 04 '14 at 11:07
  • This question appears to be off-topic because it is about [`working with a service provider's management interface, such as cPanel`](http://serverfault.com/help/on-topic). – HopelessN00b Jan 14 '15 at 09:14
  • Yeah, I said I'm working with Plesk, but if you read the comments of Alexey you will see that it has nothing to do with Plesk itself. – Timo Mämecke Jan 14 '15 at 12:58

1 Answers1

0

Plesk now has seamless Node.JS support - and its hosting, subscription etc. compatible. http://ext.plesk.com/packages/28f799af-1ff4-4bb8-9c87-a04f0f23d32e-jxcore-support

Nuray Altin
  • 116
  • 1