1·安装包下载
修改sshwifty.conf.json配置文件
"SharedKey": "设置密码",
"ListenInterface": "0.0.0.0",
修改ssh断联时间
"HeartbeatTimeout": 20,
"ReadDelay": 300,
"WriteDelay": 300,
2·LNMP环境
nginx配置文件
############################server开始####################
server {
######################访问域名及监听端口配置#############
listen 80 ;
listen [::]:80;
listen 443 ssl http2 ;
listen [::]:443 ssl http2;
server_name demo.com;
######################访问域名及监听端口配置结束#########
proxy_send_timeout 300s;
proxy_read_timeout 300s;
index index.php index.html index.htm default.php default.htm default.html;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
##################允许在HTTP头中使用下划线################
underscores_in_headers on;
######################################################
location ^~ / {
##################反代IP和端口##########################
proxy_pass http://127.0.0.1:8182;
##################反代IP和端口结束######################
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
add_header Strict-Transport-Security "max-age=31536000";
}
######################80端口重定向到443端口#############
if ($scheme = http) {
return 301 https://$host$request_uri;
}
#######################80端口重定向到443端口结束#########
#####################ssl证书配置#######################
ssl_certificate /ssl/demo.com/cert.crt;
ssl_certificate_key /ssl/demo.com/private.key;
ssl_protocols TLSv1.3 TLSv1.2 TLSv1.1 TLSv1;
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK:!KRB5:!SRP:!CAMELLIA:!SEED;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
proxy_set_header X-Forwarded-Proto https;
add_header Strict-Transport-Security "max-age=31536000";
########################证书配置结束#####################
}
###########################server结束#######################
3·配置ssl证书
4·配置开机自启动
webssh.service文件
/etc/systemd/system
[Unit]
Description=webssh服务
[Service]
ExecStart=/www/demo.com/sshwifty_linux_386 "-c" "/www/demo.com/sshwifty.conf.json"
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
使用教程详见
4·连接中断
解决方法
nginx设置超时时间;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
sshwifty设置超时时间。
"HeartbeatTimeout": 20,
"ReadTimeout": 300,
"WriteTimeout": 300
HeartbeatTimeout指示前端每隔20秒发送一次Echo请求,后端收到这个Echo之后会立即回应,前端收到来自后端的回应之后会计算延迟时间并显示在用户界面上(就是左上角的那个延迟计)。
ReadTimeout指示后端在TCP连接持续无数据到达的情况下,将会等待多久。300秒是5分钟左右,即如果TCP持续5分钟没有读出数据,Sshwifty后端会断开连接。
WriteTimeout指示后端在尝试写入TCP链接时,最大允许的等待时间(即允许Write操作执行的时间)。超过这个时间,Sshwifty也会断开连接。
Sshwifty通过ReadTimeout和WriteTimeout的设置来被动的判断TCP连接的活性。在TCP连接正常的情况下,这两个超时都不会到达,因为HeartbeatTimeout每隔20秒就会激发一次Read和Write操作,这样一来,ReadTimeout一定会在HeartbeatTimeout周期内被重设,而WriteTimeout本身只有在TCP已经被严重阻塞的情况下才不会被重设。