Fix Nginx Unknown Variable $connection_upgrade

0, Preface

Recently, I was busy moving the server. After finally moving it, I accidentally deleted the kernel and started all over again. When using Pagoda one-click migration API version, I found that when migrating to a new server, each website will report an error when it is created:

Text
1
nginx: [emerg] unknown "connection_upgrade" variable

error

So find information to solve the problem, and record it here.

2. Solution

In the main NGINX configuration file, add:

Nginx
1
2
3
4
5
6
7
8
http {
     ...
     #The default configuration is omitted above, and the following code can be added at the end
     map $http_upgrade $connection_upgrade {
         default upgrade;
         '' close;
     }
}

The function is to map the connection_upgrade variable to the http_upgrade variable.

3, the cause of the error

I don’t know which version the pagoda is in, so I added it to all reverse proxies:

Nginx
1
2
3
4
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;

To support anti-generation WebSocket connection, may be to prevent Xiaobai from going to the forum to ask questions .

Finally, it is recommended that all programs (NGINX, Apache, MySQL, PHP) be compiled and installed. Recently, I heard that compiling and installing Pagoda will cause the server to be hung up or even invaded.

Fix Nginx Unknown Variable $connection_upgrade

https://blog.tsinbei.com/en/archives/677/

Author
Hsukqi Lee
Posted on

2022-12-15

Edited on

2022-12-15

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet