2

I'm trying to setup my app on HTTPS on a web server. I have a valid certificate that is installed on my InMotion host using AutoSSL. I have the node app running on my Centos server on port 3000 and my apache SSL server running on port 443. To route requests made to my website, I am attempting to create a reverse-proxy. I made a file called default-site.conf which is stored in /etc/http.d/conf.d and has the following contents:

<VirtualHost _default_:443>
    SSLProxyEngine on

    ServerName example.com
    ServerAlias www.example.com 

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full
    <Proxy *>
      Require all granted
    </Proxy>

    ServerAdmin [email protected]
    DocumentRoot /home/USER/my-app/public

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLCertificateFile  /home/USER/ssl/certs/certificate.crt
    SSLCertificateKeyFile /home/USER/ssl/keys/certificate.key


    ProxyPass / https://example.com:3000/
    ProxyPassReverse / https://example.com:3000 /

    <Directory "/home/USER/my-app/public">
        AllowOverride All
    </Directory>        

</VirtualHost>

I will emphasize that the app is accessible at http://example.com:3000 (insecure) but when I attempt to go to https://example.com (secure) I get my blank index.html with a 404 error:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (index.js, line 0)

5
  • 1
    So the node app on port 3000 does not serve HTTPS, but HTTP? Perhaps you meant to ProxyPass(Reverse) to http://example:3000/ instead of https://example:3000/ Commented Feb 2, 2020 at 0:16
  • 1
    Also, does the node app run on the same machine as the Apache server or on another host? If it's on the same host, it might be bound to http://localhost:3000 instead of http://example.com:3000, depending on how it's set up. Commented Feb 2, 2020 at 0:20
  • I had it on http before. Both run on the same machine. Commented Feb 2, 2020 at 0:43
  • Is the error the same if you proxypass to http://? If you just console.log all requests over at the node app, does anything come through when you make the request to https://example.com? Commented Feb 2, 2020 at 0:48
  • Never mind... I just said screw it and ProxyPassed without a virtual host. Commented Feb 2, 2020 at 1:15

1 Answer 1

3

I managed to fix this issue by completely simplifying my config to the following two lines:

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

This may not be the most flexible approach but it reroutes the traffic the way I need it to be routed, so for my purposes, it works.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.