Apache SSL reverse proxy to a node server using websockets

prisma

#1

Hi Guys,

I am new to Apache, recently I am facing a crazy problem. Browsing to a root domain like https://sub.example.com and navigating through pages such as https://sub.example.com/page1 works.

But only if I start my initial connection at the root. If I refresh the browser while the URL is https://sub.example.com/page1 , I get a 404:

Cannot GET /page1

I suspect it has something to do with some initial SSL handshake but I’m just not well versed enough in this subject matter to really figure out where I should be looking. I’ve tried many different site .conf files without luck. Works fine in my dev environment using basic HTTP access.

Here is a basic config file I’ve tried:

  <VirtualHost sub.example.com:80>
      ServerName sub.example.com

      <Location />
          ProxyPass http://localhost:3020/
          ProxyPassReverse http://localhost:3020/
      </Location>

      RewriteEngine on
      RewriteCond %{SERVER_NAME} =sub.example.com
      RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
  </VirtualHost>

  <VirtualHost sub.example.com:443>
      ServerName sub.example.com

      SSLEngine on
           SSLProxyEngine On
           ProxyRequests On

      <Location />
          ProxyPass http://localhost:3020/
          ProxyPassReverse http://localhost:3020/
      </Location>

      SSLCertificateFile /etc/letsencrypt/live/sub.example.com/cert.pem
      SSLCertificateKeyFile /etc/letsencrypt/live/sub.example.com/privkey.pem
      Include /etc/letsencrypt/options-ssl-apache.conf
      SSLCertificateChainFile /etc/letsencrypt/live/sub.example.com/chain.pem

      RewriteEngine on
      RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
      RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
      RewriteRule .* ws://localhost:3020%{REQUEST_URI} [P]
  </VirtualHost>

Thanks & Regards
Camillelola


#2

Hi @camillelola26, this is a forum for questions all around Prisma :slight_smile:

I’m closing this thread as it seems to be off-topic.


#3