I'm having trouble getting Nginx to play well with the Python Flask-socketio library (which is based on gevent). Currently, as we are actively developing, I am trying to get Nginx to work only as a proxy. To send pages, I can make this work, either by directly launching the flash socket application, or by skipping the guns. One delay: messaging with websites doesn't seem to work. Pages are successfully posted and displayed. However, when I try to use websockets, they do not work. They are alive enough that websocket believes that it is connected, but they will not send a message. If I remove the Nginx proxy, they will work. Firefox gives me this error when I try to send a message:
Firefox cannot establish a connection to the server at ws: ///socket.io/1/websocket/.
If the web address is where the server is located, and the unique identifier is just a bunch of random numbers. It seems that it is doing enough to maintain a live connection (for example, the client believes that it is connected), but cannot send a message through the website. I should think that the problem is related to some part of the proxy server, but I have serious debugging problems, which can be a problem (partly because this is my first round with Flask-socketIO and nginx). The configuration file that I use for nginx:
user <user name>;
worker_processes 5;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
server_names_hash_bucket_size 128;
server {
listen 80;
server_name _;
location / {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}
}
websocket, . , werkzeug Proxy_Fix- Flask app.wsgi_app, wsgi. , . - - , /.