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.