Error 522, only when proxied (Apache2)

I’ve gone through seemingly every topic I can find about this.

I’ve checked all of:

  • Firewall, tried it with it disabled, enabled, fully allowed, etc.
  • The response status (works when directly connecting with ip)
  • KeepAlive is enabled
  • My site configuration

I just cannot figure this out. It works perfectly fine when not proxied. I am using a reverse proxy with a node.js express server with apache2 directing my traffic around. When proxy is disabled from cloudflare, it works as expected with full SSL. When I enable proxy on cloudflare, I get error 522. And I’ve exhausted all my resources here, so I figured I’d post my own issue.

I’m using a self-signed certificate from letsencrypt using my cloudflare credentials (with --dns-cloudflare --dns-cloudflare-credentials). I’m not sure if this has anything to do with it. When not proxied, the SSL works fine.

Looking for any insight on the issue, thanks.

May as well add my firewall is ufw. Ports 80, and 443 are open from anywhere. My site config looks like this:

<VirtualHost *:80>
        ServerName name

        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
        RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]

<VirtualHost *:443>
        ServerName name

        SSLEngine on
        ProxyPreserveHost on
        SSLProtocol all -SSLv2 -SSLv3

        SSLCertificateFile /etc/letsencrypt/live/name/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/name/privkey.pem

        SSLProxyEngine on
        SSLProxyVerify none
        SSLProxyCheckPeerCN off
        SSLProxyCheckPeerName off
        ProxyPass / https://localhost:4950/
        ProxyPassReverse / https://localhost:4950/

Apparently I had a copy paste error for my destination ip. It is all working just fine…