dotnet / dotnet/AspNetCore.Docs

Additional information needed for apps using SignalR/WebSocket

Open
#12,774 2 comments 2 reactions 0 assignees View on GitHub
doc-enhancement SignalR Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

When Apache is used as proxy for apps relying on WebSocket:

- The mod_proxy_wstunnel module needs to be enabled
- The virtual host configuration needs to include additional settings to allow the WebSocket connection to be established. The example at the top of the page becomes something like:

```

RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}

ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ServerName www.example.com
ServerAlias *.example.com

# Added block
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:5000/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://127.0.0.1:5000/$1 [P,L]
# End added block

ErrorLog ${APACHE_LOG_DIR}helloapp-error.log
CustomLog ${APACHE_LOG_DIR}helloapp-access.log common

```

Thanks!

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: cfd9a1f0-c1b6-4443-0700-4c5beafeed03
* Version Independent ID: c22ca7a0-d1d4-200d-fc36-a9798d350c6e
* Content: [Host ASP.NET Core on Linux with Apache](https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-3.0)
* Content Source: [aspnetcore/host-and-deploy/linux-apache.md](https://github.com/aspnet/AspNetCore.Docs/blob/master/aspnetcore/host-and-deploy/linux-apache.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-hostdeploy**
* GitHub Login: @guardrex
* Microsoft Alias: **spboyer**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.