0

I built an node express server. It runs without any trouble: http://uniformflow.com

const app = express();
const port = process.env.PORT || 3000;
app.listen(port, () => console.log('listening on ' + port));

Recently, I got an ssl certificate from letsencrypt. I ended up having a secure working apache server, which you can check at https://www.uniformflow.com

At this point, I assume my express server listens the http port. And when someone sends a request with https port, It goes to my apache server /var/www directory. How should I route this requests to my node server?

neiloth
  • 157
  • 1
  • 11

1 Answers1

0

in Apache there is no module support for node like php or perl. so you should use Apache proxy module. you can enable it using sudo a2enmod proxy proxy_http and then change its configurations in /etc/apche2/sites-availables:

<VirtualHost *:80>
    ServerAdmin admin@uniformflow.com
    ServerName uniformflow.com
    ServerAlias www.uniformflow.com 

    ProxyRequests off

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

    <Location />
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>
</VirtualHost>

then you should restart apache server. in my opinion its better to use Nginx, its very easy and i also handle ssl connection for you.

amir
  • 2,443
  • 3
  • 22
  • 49
  • thanks for the quick reply, I've seen a2enmod in several guides. I'm using Amazon Linux 2 AMI, and it gives me the error: sudo: a2enmod: command not found. – neiloth Nov 15 '19 at 08:25
  • @Meriç checkout this https://stackoverflow.com/questions/12292992/permalinks-on-wordpress-ec2 – amir Nov 15 '19 at 08:55