/ walking bear:D / Socket.io with nginx

Socket.io with nginx

2017-03-29 posted in [筆記]

stackoverflow 關於利用 nginx proxy WebSocket 的設置問答: Socket.io with nginx

nginx 官方網站的系列文章之一: Using NGINX and NGINX Plus with Node.js and Socket.IO, the WebSocket API


Get the client’s IP address in socket.io ,提到在 nginx.conf 加入:

proxy_set_header  X-Real-IP $remote_addr;
proxy_set_header  X-Real-Port $remote_port;

如此就可以在 node.js 用下列方法取得遠端 client 的 IP 地址:

var ip = socket.handshake.headers["x-real-ip"];
var port = socket.handshake.headers["x-real-port"];

目前開發使用 socket.io@1.7.2,手機端似乎會因為省電,每隔一段時間就斷開 TCP connection,然後又 reconnect。比較令人困擾的是:socket.io 會夾帶 cookie: io=xxxxxxx,此值與 socket.id 並不相同,在 reconnect 之後都會重新設定。基本上沒什麼太大用處!目前初步的想法:自己另行設定一組 session cookie,在 reconnect 之後,client/server 額外做雙方同步的動作 (To Be Verified) ref: socket io changes socket.id repeatedly


如何 trigger firefox 的 Reader View? — 原來是我的 post 都偏短,至少要有一段 paragraph 內文要超過 516 個字 (utf8?)

You need at least one <p> tag around the text, you want to see in Reader View and at least 516 characters in 7 words inside the text. for example this will trigger the ReaderView: 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456 — stuffing five hundred and fifty six characters . reply_count: 1 get_replies : 1 . 2017-04-12_21:21:19 tachikoma

walking bear:DRSS feed

关于

wkliang

Clarke's Three Laws:

  • When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
  • The only way of discovering the limits of the possible is to venture a little way past them into the impossible.
  • Any sufficiently advanced technology is indistinguishable from magic.
  • 版权申明

    知识共享许可协议

    Fork me on GitHub

    Powered by

    Disqus, GitHub, Google Custom Search, Gravatar, HighlightJS, jekyll