0

I am trying to configure apache2 on aws lightsail instance. the instance was default setup for aws wordpress + aws linux. I have a node.js server running on port 5000 on this instance.

the apache server is in /opt/bitnami/apache2.

First I tried to redirect port to 5000 for non-http requests ad it worked well.

here is the .conf file:

<VirtualHost *:80>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName example.com
  ServerAlias www.example.com

  # setup the proxy
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>

  ProxyPass / http://example:5000/
  ProxyPassReverse / http://example:5000/
</VirtualHost>

then I configured ssl certificate with bitnami bncert-tool. I turned force https redirect on while configuring ssl.

then i configured example-https.conf like below:

<VirtualHost *:80>
  ProxyPreserveHost On
  ProxyRequests Off

  ServerName example.com
  ServerAlias www.example.com

  SSLEngine on
  SSLCertificateFile "/opt/bitnami/apache2/conf/example.com.crt"
  SSLCertificateKeyFile "/opt/bitnami/apache2/conf/example.com.key"

  # setup the proxy
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>

  ProxyPass / http://example.com:5000/
  ProxyPassReverse / http://example.com:5000/
</VirtualHost>

but this time it's not working. requests are being redirected to https and resposes is from wordpress, not my node.js server.

these conf files are in /var/www and i have included them in httpd.conf using

Include "/var/www/*.conf"

2 Answers2

0

fixed it by replacing <VirtualHost *:80> with <VirtualHost *:443> on the example-https.conf file

still waiting for a better answer, thanks.

0

Bitnami Engineer here,

You can deploy a custom Node application on top of the Bitnami solution by following these steps:

  • Run the following commands to create the directories:

    sudo mkdir -p /opt/bitnami/myapp
    sudo mkdir /opt/bitnami/myapp/conf
    sudo mkdir /opt/bitnami/myapp/htdocs
    
  • Create and edit the /opt/bitnami/myapp/conf/httpd-prefix.conf file and add the line below to it:

    Include "/opt/bitnami/myapp/conf/httpd-app.conf"
    
  • Create and edit the /opt/bitnami/myapp/conf/httpd-app.conf file and add the content below to it. This is the main configuration file for your application, so modify it further depending on your application's requirements.

    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/
    

    NOTE: 3000 is the default port for the Express server. If you have customized your application to use a different port, change it here as well.

  • Once you have created the files and directories above, add the following line to the end of the main Apache configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf, as shown below:

    Include "<%= variable :app_directory, :platform %>/myapp/conf/httpd-prefix.conf"
    
  • Restart the Apache server:

    sudo /opt/bitnami/ctlscript.sh restart apache
    

You can now use the Bitnami HTTPS configuration tool to generate Let's Encrypt certificates and access your application using http and https.

Jota Martos
  • 301
  • 1
  • 4