Skip to content
Discussion options

You must be logged in to vote

解决方式:
1.根据自己项目的实际情况修改websocket.lua的read_handshake方法里获取真实IP的部分:

    ......
    -- read 'x-real-ip' header from nginx
    self.real_ip = header["x-real-ip"]
        or header["cf-connecting-ip"]
        or (header["x-forwarded-for"] and string.match(header["x-forwarded-for"], "([^,]+)"))
   ......

2.也可以自己在websocket的回调handle.handshake(_socket_id, _header, _url)里在_header里提取出真实IP

推荐方法二

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@LuckCome
Comment options

@BanKnight
Comment options

@sniper00
Comment options

@BanKnight
Comment options

Comment options

You must be logged in to vote
1 reply
@LuckCome
Comment options

Comment options

You must be logged in to vote
1 reply
@LuckCome
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by LuckCome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants