Skip to content

Commit

Permalink
fixes #22: document use of nginx as a reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jun 8, 2014
1 parent 6c995a5 commit 9ed9b07
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/index.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,36 @@ Note regarding *uWSGI*: while this server has support for *gevent*, there is no

Note regarding reverse proxies: If your application runs behind a reverse proxy such as *nginx*, then make sure the reverse proxy is configured to also proxy WebSocket connections.

Using nginx as a WebSocket Reverse Proxy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It is also possible to use *nginx* as a reverse proxy that passes regular and socket requests to the application. However, it is important to note that only releases of nginx 1.4 and newer support proxying of the WebSocket protocol. Below is an example nginx configuration::

server {
listen 80;
server_name localhost;
access_log /var/log/nginx/example.log;

location / {
proxy_pass http://127.0.0.1:5000;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /socket.io {
proxy_pass http://127.0.0.1:5000/socket.io;
proxy_redirect off;
proxy_buffering off;

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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}

0 comments on commit 9ed9b07

Please sign in to comment.