dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.44k stars 25.33k forks source link

Additional information needed for apps using SignalR/WebSocket #12774

Open AlbertoPa opened 5 years ago

AlbertoPa commented 5 years ago

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

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

<VirtualHost *:80>
    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
</VirtualHost>

Thanks!


Document Details

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

guardrex commented 5 years ago

Thanks @AlbertoPa ... I'll mark this for the Product Unit (PU label) to take a look at for coverage. They'll either work it directly on the next engineering doc sweep or give me instructions on what to cover where. Thanks for opening the issue.

donhuvy commented 4 years ago

I have a hard time for deploying, this is my experience about this task https://stackoverflow.com/questions/58196221/asp-net-core-3-blazor-run-on-localhost-of-server-ok-but-run-outside-server-err