-
I believe I've configured nginx properly to proxy websockets however Falcon isn't responding properly; returns a I'm running falcon via: nginx config ...
4
5 upstream w3d_battleview {
6 server 127.0.0.1:9696;
7 }
8
...
12
13 server {
14 listen 80;
15 listen [::]:80;
16
17 server_name [SERVER_NAME];
18
19 return 301 https://$server_name$request_uri;
20 }
21
22 server {
23 listen 443 ssl;
24
25 server_name [SERVER_NAME];
26 root [---];
27 gzip on;
28 gzip_types *;
29 gzip_min_length 512;
30 ssl_certificate /etc/letsencrypt/live/[---]/fullchain.pem; # managed by Certbot
31 ssl_certificate_key /etc/letsencrypt/live/[---]/privkey.pem; # managed by Certbot
32 error_log [---]/w3d_error.log warn;
33
...
41
42 # Handle websocket upgrade for battleview
43 location /battleview/api/v1/websocket {
44 proxy_pass http://w3d_battleview/;
45 proxy_http_version 1.1;
46 proxy_set_header Upgrade $http_upgrade;
47 proxy_set_header Connection "Upgrade";
48 proxy_set_header Host $host;
49 proxy_set_header X-Forwarded-Proto $scheme;
50 proxy_set_header X-Forwarded-Host $host/battleview/;
51 proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
52 }
53
54 location /battleview/ {
55 proxy_pass http://w3d_battleview/;
56 proxy_set_header Host $host;
57 proxy_set_header X-Forwarded-Proto $scheme;
58 proxy_set_header X-Forwarded-Host $host/battleview/;
59 proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
60 }
...
69
70 location / {
71 try_files $uri $uri/ =404;
72 }
73 } Log segment:
Sample config.ru require "sinatra/base"
class Web < Sinatra::Base
get "/" do
"HELLO WORLD"
end
end
require "async/websocket/adapters/rack"
class WebSocketServer
def call(env)
Async::WebSocket::Adapters::Rack.open(env, protocols: ['ws']) do |connection|
connection.write({ data: "HELLO WORLD" })
connection.close
end
end
end
map "/websocket" do
run WebSocketServer.new
end
run Web |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It should work, I don't have any immediate idea why it doesn't. Maybe the way the connection is being forwarded is a bit odd (nginx config). |
Beta Was this translation helpful? Give feedback.
-
Okay, for some reason Falcon thinks that the request path is |
Beta Was this translation helpful? Give feedback.
-
Ah, yes, I had proxy_pass set incorrectly; The Maybe Falcon's |
Beta Was this translation helpful? Give feedback.
Ah, yes, I had proxy_pass set incorrectly; The
proxy_pass
needed to have the full "path" in it:proxy_pass http://w3d_battleview/api/v1/websocket;
Maybe Falcon's
--verbose
mode could include the request path, and not only the headers, to make this error more apparent?