There is no problem in setting up agents in general settings, but today we have to operate websockt.

 Server {
location / {
proxy_pass http://127.0.0.1:10086; 
proxy_set_header Host $host; 
proxy_set_header X-Real-IP $remote_addr; 
proxy_set_header 
proxy_set_header; 1.1;

Nginx -t Once

The following errors will occur:
Nginx: [emerg] unknown "connection_upgrade" variable

This is where there is a pit.

It involves a design problem of nginx. End-to-end and Hop-by-hop Headers
I am still talking about it here, so as not to mislead my children.

Map sets up mapping tables for one or more variables in nginx.

Here are a few configurations to add:

 Http {
map $http_upgrade $connection_upgrade {
default upgrade; '' 'close; 
}

server {
location / { 
proxy_set_header Upgrade $http_upgrade; 
proxy_set_header Connection $connection_upgrade;}}}}

Label: Nginx , Websocket

There are 3 comments.

  1. [...] although the problem has been solved, I want to know why it happened and the real principle of the solution. In this blog, you can see that the problem is on the nginx agent websocket. What is websocket's traditional HTTP communication mode is: the client initiates the request, the server receives the request and responds. The websocket protocol reuses the handshake channel of HTTP, specifically referring to the client's negotiation with the WebSocket server through the HTTP request. The first step is to establish a connection, and the client uses HTTP newspaper [...].

  2. Have you taught me how to do VPN?

Add new comments

This page loaded in 0.000881 seconds