Reputation: 101
So, I have an apache server which listens to all the requests. Now I wanted to run a node https server app to listen on port 9001. When I create the https server and make it listen to 9001, it seems to work on localhost on the same machine. So, if I access https://localhost:9001 I get the page I want. But when I access the public website from outside, along with the port 9001 I receive it on Apache.
My configuration is an Amazon Linux AMI
Upvotes: 0
Views: 1063
Reputation: 71
The exact configuration of your Apache server isn't given here; however, it is most like to be ONLY listening for requests on port 80 (the normal HTTP port).
Since you are running on AWS, you probably set up your instance with a Security Group that is set to allow inbound connections on port 80. (I believe most guides I've seen have you set up the inbound rules in your Security group to also open port 22 for SSH connection to the instance, though that's an aside here as it doesn't affect Apache, but perhaps this is familiar now that I mention it?).
If you are running your Node server and have it set to listen to port 9001 but are not exposing port 9001 to the internet in your Security Group it will, in fact, only be reachable from the localhost.
There are two things you could do here:
1) In the AWS Console, update the Security Group for your instance to allow inbound connections on the target port (9001).
This will function but it's far from preferable as you expose your application directly which can present security issues.
2) You can set up ProxyPass
and ProxyPassReverse
in the Apache configuration (or an appropriate vhost.conf, etc.) to leverage Apache's reverse proxy functionality and add the https://localhost:9001 as the destination for the inbound requests. (You may need to use the IP for localhost -- https://127.0.0.1 -- as the destination. For HTTPS, you will also need to be sure Apache is set up to read your cert and that the SSLProxyEngine
be included and on
.
(From what I gather, nginx is the most common thing to place out in front of a Node application as a reverse proxy, but Apache can serve in this role.)
Upvotes: 1