用于Clojure WebSocket应用程序的Nginx产品设置 [英] nginx prod setup for Clojure WebSocket app

查看:70
本文介绍了用于Clojure WebSocket应用程序的Nginx产品设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署我的第一个Clojure WebSocket应用,我想我已经接近了。我在本地得到了很好的响应,并且好像端点想面对外界(我在运行 netstat 时看到端口是开放的),但是没有响应。我确定我在 nginx 中设置有误。

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.

我目前已经在该服务器,只需添加必要的配置即可获取对 wss://domain.com:8001 发出的请求,以与我的应用进行通信。

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.

** 编辑: **对于感兴趣的各方,我将工作配置(基于Erik Dannenberg的回答)放在 gist 中。

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

推荐答案

您还缺少两个标头,这是一个最小的工作配置:

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;
}

这篇关于用于Clojure WebSocket应用程序的Nginx产品设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆