dryan / decss-sync

A tornado.py web app for syncing Decss presentations.
http://dryan.github.io/decss-sync
MIT License
2 stars 0 forks source link

nginx config example #1

Closed cgansen closed 10 years ago

cgansen commented 10 years ago

I ran into a little quirk of nginx when setting this up.

On my web client, I saw a bunch of errors in the console: Error during WebSocket handshake: Unexpected response code: 400

Turns out you need some magic in nginx to reverse proxy websocket connections, namely this incantation:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

More: http://nginx.org/en/docs/http/websocket.html

Here is a complete, working nginx config, if it's helpful to other folks:

upstream decss-sync-server {
    server 127.0.0.1:9000 max_fails=3 fail_timeout=1s;
}

server {
  listen        80;
  server_name   decss-sync.example.com;

  charset       utf-8;
  access_log    /var/log/nginx/decss-sync.access.log;
  error_log     /var/log/nginx/decss-sync.error.log;

  root          /opt/decss-sync;

  location  / {
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://decss-sync-server;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
  }
}
dryan commented 10 years ago

is there a way to turn this into a markdown file we can put in the repo?