The original post: /r/nginx by /u/Glass_Builder_9233 on 2024-09-17 15:54:23.
I'm using flask_socketio to handle WebSocket communication, but for some reason, it's only connecting to the server without emitting any messages to the events. After about a minute, it times out. It works fine locally but when using the deployed version it doesn't work. Any ideas on what could be causing this?
user nginx;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name [domain] [domain];
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name [domain] [domain];
ssl_certificate /etc/letsencrypt/live/[domain]/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/[domain]/privkey.pem;
location / {
proxy_pass [backend server];
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /socket.io/ {
proxy_pass [backend server];
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}
}
You must log in or register to comment.