doudong0425 2014-09-15 13:26
浏览 119
已采纳

php websocket重定向与stunnel

I built a php websocket server javascript clients to connect to it. It's working fine without SSL. My next Step is to improve security with using wss instead of ws (an so enabling https on the website).

My intention is to decrypt incoming traffic and redirect it to the websocketserver using stunnel on CentOS 6.

The first step is to simply redirect the requests from the clients to the server:

client-request: ws://soundjack.eu:9030/wsServer2.php

server: socket created listening on 144.76.81.210:9090 running php -q wsServer2.php

coresponding stunnel config:

; Some security enhancements for UNIX systems - comment them out on Win32
chroot = /var/run/stunnel/
;setuid = nobody
;setgid = nobody
; PID is created inside the chroot jail
pid = /stunnel.pid

; Some performance tunings
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
;compression = zlib

; Some debugging stuff useful for troubleshooting
debug = 7
output = /var/log/stunnel/stunnel.log

; Use it for client mode
client = yes

; Service-level configuration
[wsServer]
accept = 127.0.0.1:9030
connect = 127.0.0.1:9090

stunnel starts correct and is listening to port 9030.

Every request that is sendet by a client gehts abortet (checked firebug console). On Chrome it says status: finished, without any further information.

I quite don't know what the error is, so any help would be great. Thanks!

  • 写回答

2条回答 默认 最新

  • dongrong7267 2014-09-15 16:37
    关注

    It finaly works!!! Even with SSL it works great.

    The clue was to chance the config of stunnel to work correct (Update using SSL now):

    /etc/stunnel/stunnel.conf:

    ; Certificate/key is needed in server mode and optional in client mode
    cert = /path/to/<myCert>.pem
    key = /path/to/<myKey>.key
    
    ; Protocol version (all, SSLv2, SSLv3, TLSv1)
    sslVersion = all
    
    ; Some security enhancements for UNIX systems - comment them out on Win32
    chroot = /var/run/stunnel/
    
    ; PID is created inside the chroot jail
    pid = /stunnel.pid
    
    ; Some performance tunings
    socket = l:TCP_NODELAY=1
    socket = r:TCP_NODELAY=1
    ;compression = zlib
    
    ; Some debugging stuff useful for troubleshooting
    debug = 7
    output = /var/log/stunnel/stunnel.log
    ;foreground = yes
    
    ; Use it for client mode
    ;client = yes                     !! turn to server mode
    
    ; Service-level configuration
    [wsServer]
    accept = 0.0.0.0:9030             !! listen to all addresses
    connect = 127.0.0.1:9090
    

    Note: marks with !! are no valid comments! I inserted them only to show the changes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架