- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在用这个setting把haproxy放在node.js和socket.io前面。
haproxy设置中的部分代码:
frontend wwws
bind 0.0.0.0:443 ssl crt /etc/haproxy/ovee.pem
timeout client 1h
default_backend www_backend
acl is_websocket hdr(Upgrade) -i WebSocket
use_backend websocket_backend if is_websocket
tcp-request inspect-delay 500ms
tcp-request content accept if HTTP
use_backend flashsocket_backend if !HTTP
frontend flash_policy
bind 0.0.0.0:843
timeout client 5s
default_backend nodejs_flashpolicy
backend www_backend
balance roundrobin
option forwardfor
server apache2 apache-backend:3001 weight 1 maxconn 1024 check
timeout connect 5s
timeout http-request 3s
timeout server 25s
backend websocket_backend
mode http
option forwardfor
option http-server-close
option forceclose
no option httpclose
server server1 socket-backend:3000 weight 1 maxconn 16384 check
nodeServer.js
var fs = require('fs');
var express = require('express'),
app = express(),
http = require('http').createServer(app),
io = require("socket.io").listen(http),
它似乎在第一次连接时运行良好,但随后浏览器阻止了所有针对混合内容
的套接字连接尝试。
The page at 'https://domain.com/391' was loaded over HTTPS,
but requested an insecure XMLHttpRequest endpoint
'http://domain.com:3000/socket.io/?EIO=3&transport=polling&t=1456666556035-0'.
This request has been blocked; the content must be served over HTTPS.
我知道这是因为我与 socket.io 的连接是通过 Http
而不是 Https
客户端.js
socket = io.connect('http://domain.com:3000', {
'force new connection': false,
'reconnection delay': 500,
'max reconnection attempts': 10
}),
我已经尝试对 nodeServer.js 使用 SSL,但是它没有连接到套接字,而且我认为没有必要,因为我正在使用 haproxy 进行所有转发:
在 nodeServer.js 中,我更改为:
var fs = require('fs'),
sslOption = {
key: fs.readFileSync('/ssl/crt/zz.key'),
cert: fs.readFileSync('/ssl/crt/zz.crt'),
ca: fs.readFileSync('/ssl/crt/zz-ca.crt'),
requestCert: true
},
express = require('express'),
app = express(),
https = require('https').createServer(app),
io = require("socket.io").listen(https),
客户端.js
socket = io.connect('https://domain.com:3000', {
'force new connection': false,
'reconnection delay': 500,
'max reconnection attempts': 10
}),
有人把haproxy放在node.js和socket.io前面吗?我应该使用什么从 client.js 连接到 socket.io?
最佳答案
我已经以某种方式解决了这个问题。我不应该在 client.js
中使用 https:domain.com:3000
。我应该让 haproxy 做 SSL 转发。这是我使 SSL 与 socket.io 一起工作的设置。我希望可能偶然发现它的人会纠正任何过时或错误的内容:
frontend www
bind 0.0.0.0:80
mode http
timeout client 5s
redirect scheme https if !{ ssl_fc }
acl is_socket hdr(Upgrade) -i WebSocket
acl is_socket hdr_beg(Host) -i wss
use_backend socket if is_socket
frontend www-https
bind 0.0.0.0:443 ssl crt /ssl/domain.pem
timeout client 1h
### Set up a check to identify the connection url initated by socket.io https://domain.com/socket.io/?EIO=3&transport=polling&t=1441877956651, if matched, forward to node backend
acl is_node path_beg /socket.io/
use_backend node if is_websocket
### I'm not sure if this one is necessary for wss://domain.com
acl is_websocket2 hdr(Upgrade) -i WebSocket
acl is_websocket2 hdr_beg(Host) -i ws
use_backend socket if is_websocket2
default_backend apache2
tcp-request inspect-delay 500ms
tcp-request content accept if HTTP
use_backend flashsocket_backend if !HTTP
frontend flash_policy
bind 0.0.0.0:843
timeout client 5s
default_backend nodejs_flashpolicy
### setting for apache, skipped because it's not the focus of the question
backend apache
###
backend flashsocket_backend
server server1 ipaddress:3000 weight 1 maxconn 16384 check
backend nodejs_flashpolicy
server server1 ipaddress:10843 maxconn 16384 check
backend node
mode http
timeout server 1h
timeout connect 1s
option httpclose
option forwardfor
server server1 ipaddress:3000 weight 1 maxconn 1024 check
backend socket
balance roundrobin
option forwardfor
option httpclose
timeout queue 5000
timeout server 86400000
timeout connect 86400000
server server1 127.0.0.1:9000 weight 1 maxconn 1024 check
然后在client.js中,我把连接地址改成了:
socket = io.connect('https://domain.com', {
'force new connection': false,
'reconnection delay': 500,
'max reconnection attempts': 10,
})
使用“https://domain.com” ' 而不是 'http://domain.com:3000 ' 这样连接将首先传递给 ha-proxy。
在 nodeServer.js
中不需要更改任何内容。继续使用 http
,Haproxy 将为您完成所有 SSL 转发。
var fs = require('fs'),
express = require('express'),
app = express(),
http = require('http').createServer(app),
io = require("socket.io").listen(http),
关于javascript - 如何使用 SSL 将 haproxy 放在 socket.io 前面?获取混合内容警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32496765/
我当前项目中的许多类都有几个只能从类本身内部调用的属性和方法。此外,根据类(class)的当前状态,它们可能会扰乱类(class)的工作。 目前,所有这些接口(interface)都在 .h 文件的主
我想使用ngbTabSet将nav-pills in card-header 和tab-content in card-body。但我不知道该怎么做。 这是我尝试实现的示例(使用 bootstrap.
我正在浏览文档以查找如何允许放置在停靠栏图标上。据我所知,建议您使用 LSItemContentTypes,因为 CFBundleTypeOSTypes 已弃用。但是,我无法让 LSItemConte
我正在尝试在书签中使用 jquery UI 作为 slider 。并且 jquery ui 要求在普通 jquery 文件之后包含该文件。 所以到目前为止我所尝试的只是将脚本附加到 header ,同
您好,我尝试了广泛的谷歌搜索,但似乎没有任何帮助。 这是我的场景: 公司 Logo 存储在外部域/网址(矩形)中。 带有谷歌地图的 Ionic 应用程序,将这些 Logo 作为标记放置在 map 上。
我今天在阅读我的一些 C# 代码时发现了这一行: if (ProgenyList.ItemContainerGenerator.Status != System.Windows.Controls.Pr
我刚遇到this question在 Go FAQ 中,它让我想起了困扰我一段时间的事情。不幸的是,我真的不明白答案是什么。 似乎几乎所有非 C 类语言都将类型放在变量名之后,如下所示: var :
这是有效的 HTML 吗? 最佳答案 作为元素可以包含 phrasing content ,以及属于该组,则有效。 从语义上(并且具有一些常识),如果唯一的内容是 , 不;如果它同时包含文本和图像
这是有效的 HTML 吗? 最佳答案 作为元素可以包含 phrasing content ,以及属于该组,则有效。 从语义上(并且具有一些常识),如果唯一的内容是 , 不;如果它同时包含文本和图像
我有两本 T.Parr 写的关于 ANTLR 的书,我到处都看到美元符号和符号的引用。它也对我有用: term : IDENT -> { new TokenNode($IDENT) }; 或更复杂的东
我在实现段控制时遇到了一些问题。因为我希望它是一个固定的标题,所以当我滚动时我总是可以看到它,我已经在 - (UIView *)tableView:(UITableView *)tableView v
我有一个 20x36px (10x18pt) 的箭头图像,当我选择一个 UIImageView 时,将它拖到我的 View Controller 上然后设置图像,它总是模糊的。我只在我的项目中包含 @
How can I put background image when I hover a link Insert Bg in this a when hov
我需要在我的 .container 中添加(最新的第一个)新分区,但在 .controls (按钮)之后。可能吗? 注意:添加新的分区来保存按钮下方的前置控件对我来说不是一个选择。 HTML 需要保持
我是一名优秀的程序员,十分优秀!