Score:0

Nginx and WebSocket Unexpected server response: 400

tv flag

I'm trying to deploy a NodeJS websocket server to my Cent OS machine which running Nginx, I'm trying to make socket.mydomain.com for the socket and I used the following configuration for nginx

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

server {
    listen ip:80;
    server_tokens off;
    server_name socket.mydomain.com;

    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        proxy_http_version 1.1;
        proxy_pass             http://127.0.0.1:6001;
        proxy_read_timeout     60;
        proxy_connect_timeout  60;
        proxy_redirect         off;

        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

When I try to connect using the server IP it works fine, but when I try to use the domain I got Connection Failed: Unexpected server response: 400
and the nginx access logs also says 400

41.69.136.9 - - [26/Oct/2022:13:50:23 +0200] "GET /app/A%D*G-Ka?protocol=7 HTTP/1.1" 400 157 "-" "-"
41.69.136.9 - - [26/Oct/2022:13:51:59 +0200] "GET /app/A%D*G-Ka?protocol=7 HTTP/1.1" 400 157 "-" "-"
41.69.136.9 - - [26/Oct/2022:13:52:01 +0200] "GET /app/A%D*G-Ka?protocol=7 HTTP/1.1" 400 157 "-" "-"

I think there's something with nginx cuz when I try to use the IP direct it works

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.