nginx prod setup for Clojure WebSocket app

六月ゝ 毕业季﹏ 提交于 2020-01-15 05:33:11

问题


I'm trying to deploy my first Clojure WebSocket app and I think I'm getting close. I get a good response locally, and it looks like the endpoint wants to face the outside world (I see that the port is open when I run netstat), but no response. I'm certain that I have something setup incorrectly in nginx.

I currently already host a few other websites on this server, just want to add the necessary config to get requests made to wss://domain.com:8001 to communicate with my app.

Here is the location entry I'm using now:

location / {
  proxy_pass http://localhost:8001;
  proxy_http_version 1.1;
  proxy_set_header Connection "";
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_redirect off;
  access_log /var/www/logs/test.access.log;
  error_log /var/www/logs/test.error.log;
}

Could anyone help point me in the right direction? My guess is that I actually have too much in the config, and what's there is probably not correct.

** EDIT: ** For interested parties, I put up my working config (based on Erik Dannenberg's answer) in a gist.


回答1:


You are missing two more headers, a minimal working config:

location  /  {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    # add the two below
    proxy_set_header Upgrade websocket;
    proxy_set_header Connection upgrade;
    # optional, but helpful if you run into timeouts
    proxy_read_timeout 86400;
}


来源:https://stackoverflow.com/questions/49991548/nginx-prod-setup-for-clojure-websocket-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!