I have been trying to get nginx to play well with socket.io and my ssl configuration for a while. I can get to my site perfectly fine (over https) and everything functions properly except for the socket.io communication and when I open the debugging console I don’t see any WS available or running. My config file is like this:
server {
listen [::]:80;
listen 80;
server_name www.mywebsite.com;
access_log /var/log/nginx/access.log;
proxy_set_header X-Forwarded-Proto $scheme;
if ( $http_x_forwarded_proto != 'https' ) {
return 301 https://$host$request_uri;
}
location / {
proxy_pass http://127.0.0.1:8000;
include proxy_params;
}
location /socket.io/ {
include proxy_params;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:8000/socket.io/;
}
}
and my app is running with flask/gunicorn:
gunicorn --timeout=300 -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
Any help would be greatly appreciated!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello, @ecda909
May I ask if you have checked our tutorial on how to server flash applications with gunicorn and Nginx:
If you’re not running Ubuntu 18.04 you can choose a different distro from here: https://www.digitalocean.com/community/tutorial_collections/83
Hope this helps. Let me know how it goes.
Regards, Alex
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.