0

Problem with Blazor Test application. I run this app. over Apache server with proxy:

 <VirtualHost *:*>
    RequestHeader set \"X-Forwarded-Proto\" expr=%{REQUEST_SCHEME}
 </VirtualHost>

 Listen 192.168.0.190:44366
# for ASP.NET app TestBlazor
  <VirtualHost 192.168.0.190:44366>
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:44366/
    ProxyPassReverse / http://127.0.0.1:44366/
    ServerName 192.168.0.190:44366
  #  ServerAlias 192.168.0.190:44366
 </VirtualHost>

However, a message appears every minute: Attempting to reconnect to the server. Where can be problem ? Firefox console:

  • Maybe the problem is that: [2022-01-19T09:40:39.438Z] Error: Failed to start the transport 'WebSockets': Error: There was an error with the transport. – Vaidas ZN Jan 19 '22 at 09:53

1 Answers1

0

I found the answer here:WebSockets and Apache proxy : how to configure mod_proxy_wstunnel?

Virtual host must be configured as follows:

<VirtualHost *:*>
    RequestHeader set \"X-Forwarded-Proto\" expr=%{REQUEST_SCHEME}
 </VirtualHost>
 
  Listen 192.168.0.190:44366
# for ASP.NET app TestBlazor
  <VirtualHost 192.168.0.190:44366>
    ServerName 192.168.0.190:44366
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:44366/$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*)           http://localhost:44366/$1 [P,L]
    ProxyPass / http://localhost:44366/
    ProxyPassReverse / http://localhost:44366/
 </VirtualHost>