You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: aspnetcore/host-and-deploy/linux-nginx.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,7 @@ server {
145
145
}
146
146
```
147
147
148
-
If the app is a Blazor Server app that relies on SignalR WebSockets, see <xref:blazor/host-and-deploy/server#linux-with-nginx> for information on how to set the `Connection` header.
148
+
If the app is a SignalR or Blazor Server app see <xref:signalr/scale#linux-with-nginx> and <xref:blazor/host-and-deploy/server#linux-with-nginx>respectively for more information.
149
149
150
150
When no `server_name` matches, Nginx uses the default server. If no default server is defined, the first server in the configuration file is the default server. As a best practice, add a specific default server which returns a status code of 444 in your configuration file. A default server configuration example is:
For more information, see [NGINX as a WebSocket Proxy](https://www.nginx.com/blog/websocket-nginx/).
144
+
When multiple backend servers are used, sticky sessions must be added to prevent SignalR connections from switching servers when connecting. There are multiple ways to add sticky sessions in Nginx. Two approaches are shown below depending on what you have available.
145
+
146
+
The following is added in addition to the previous configuration. In the following examples, `backend` is the name of the group of servers.
147
+
148
+
With [Nginx Open Source](https://nginx.org/en/), use `ip_hash` to route connections to a server based on the client's IP address:
149
+
150
+
```nginx
151
+
http {
152
+
upstream backend {
153
+
# App server 1
154
+
server http://localhost:5000;
155
+
# App server 2
156
+
server http://localhost:5002;
157
+
158
+
ip_hash;
159
+
}
160
+
}
161
+
```
162
+
163
+
With [Nginx Plus](https://www.nginx.com/products/nginx), use `sticky` to add a cookie to requests and pin the user's requests to a server:
Finally, change `proxy_pass http://localhost:5000` in the `server` section to `proxy_pass http://backend`.
179
+
180
+
For more information on WebSockets over Nginx, see [NGINX as a WebSocket Proxy](https://www.nginx.com/blog/websocket-nginx).
181
+
182
+
For more information on load balancing and sticky sessions, see [NGINX load balancing](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).
183
+
184
+
For more information about ASP.NET Core with Nginx see the following article:
185
+
*<xref:host-and-deploy/linux-nginx>
115
186
116
187
## Third-party SignalR backplane providers
117
188
@@ -123,4 +194,4 @@ For more information, see [NGINX as a WebSocket Proxy](https://www.nginx.com/blo
123
194
For more information, see the following resources:
124
195
125
196
*[Azure SignalR Service documentation](/azure/azure-signalr/signalr-overview)
126
-
*[Set up a Redis backplane](xref:signalr/redis-backplane)
197
+
*[Set up a Redis backplane](xref:signalr/redis-backplane)
0 commit comments