0

I have a problem. Apache listens on a white ip and proxies all requests /ssd on nginx that proxies requests /city-dashboard to another server with websockets. In apache config:

ProxyPass /ssd/ http://10.127.32.24
ProxyPassReverse /ssd/ http://10.127.32.24

nginx config: on nginx.conf:

 map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}
include /etc/nginx/conf.d/*.conf;

on default.conf

 location /city-dashboard/stream {
     proxy_pass http://10.127.32.24:5000/stream;
     proxy_set_header Host $host;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection $connection_upgrade;
 }

Request headers:

Connection: Upgrade
Upgrade: Websocket

Response headers:

Connection: close
Status Code 400 Bad Request

what am I doing wrong?

reddaemon
  • 11
  • 2
  • 6

1 Answers1

0

What about authorization header in request ? it seems authorization problem.

  • Can you check connection and upgrade header values? these shoulde be upgrade for connection header and websocket for upgrade header. – Ali Kemal Saglam Jul 29 '15 at 13:59
  • In request it's true, but in response is not present these headers – reddaemon Jul 30 '15 at 20:27
  • these are sufficient for handshake request. can you put more info about request here? it might be corrupted headers or payload but payload is not required to websocket handshake. – Ali Kemal Saglam Jul 30 '15 at 20:37
  • It's request:`GET ws://x.x.x.x/ssd/city-dashboard/stream HTTP/1.1 Host: x.x.x.x Connection: Upgrade Pragma: no-cache Cache-Control: no-cache Upgrade: websocket Origin: http://x.x.x.x Sec-WebSocket-Version: 13 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 Sec-WebSocket-Key: 881o9c/z3Q437JFCti3BIw== Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits` – reddaemon Jul 30 '15 at 20:48
  • It's response: `HTTP/1.1 400 Bad Request Date: Thu, 30 Jul 2015 20:46:15 GMT Server: nginx/1.8.0 Content-Type: text/html; charset=UTF-8 Content-Length: 54 Vary: Accept-Encoding Content-Encoding: gzip Via: 1.1 app-test.localdomain Connection: close` – reddaemon Jul 30 '15 at 20:52
  • i tried this, but result is the same `Error during WebSocket handshake: Unexpected response code: 400` – reddaemon Jul 30 '15 at 21:06
  • No, through 2 or more proxies websockets are couldn't to run – reddaemon Jan 20 '17 at 15:04