Using Apache HTTPD as reverse proxy: Unexpected Upgrade DERP error

Hello,

I am using Apache HTTPD as reverse proxy, with the following configuration for our virtual host:

<VirtualHost *:443>
  SSLEngine On

  # Certificat
  ...

   ServerName coder.company.com

  ProxyPreserveHost On
  ProxyRequests off
  ProxyPass / http://coder:7080/
  ProxyPassReverse / http://coder:7080/

  <Location "/derp">
    RequestHeader set Connection "Upgrade"
    RequestHeader set Upgrade "websocket"
    Proxypass ws://coder:7080/derp
  </Location>

  RewriteEngine on

  RewriteCond %{HTTP:Connection} Upgrade [NC]
  RewriteCond %{HTTP:Upgrade} websocket [NC]
  RewriteRule /(.*) ws://coder:7080/$1 [P,L]

  # Custom log file for SSL
  ErrorLog /ssl.error.log
  CustomLog /ssl.access.log combined
</VirtualHost>

<VirtualHost *:80>
  ServerName coder.company.com
  RewriteEngine On
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>


Coder dashboard works. I can create templates and workspaces. However, connection to a workspace does not work.

From the Apache HTTPD error logs, I can see this error

[Mon Feb 06 07:47:39.762418 2023] [proxy:error] [pid 9:tid 140558106359552] [client 192.168.164.94:37880] AH00898: Unexpected Upgrade: DERP (expecting websocket) returned by /derp


I've seen this issue DERP requires connection upgrade but the proposed workaround to switch to caddy does not suit me.

Any idea to complete my Apache HTTPD configuration?
Was this page helpful?