I am looking for how to configure/allow socket connections on my vps. Currently I have deployed an API that supports websockets except that it just doesn't work on production. Unable to establish a socket connection, only http requests work. I have tried some configs on the nginx server but it has no effect.
The Api runs on port 8000 // server.listen(8000).
So in the sites-enabled folder of nginx I created a file with the name of app domain and I edited this file like this:
server {
location / {
proxy_pass http://localhost:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
And i edited .htaccess file inside app folder like this :
DirectoryIndex disabled
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:8000/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:8000/$1 [P,L]