搭建webssh和nginx反向代理

0、前置条件,centos主机安装了python3和nginx
 
1、安装webssh
pip3 install webssh
 
2、添加自定义服务
 
systemctl cat webssh 
# /usr/lib/systemd/system/webssh.service
[Unit] 
Description=WebSSH terminal interface 
After=network.target 

[Service] 
ExecStart=/bin/bash -c "/usr/local/share/python3/bin/wssh --address='127.0.0.1' --port=6666"
#ExecStart=/usr/local/share/python3/bin/wssh

[Install] 
WantedBy=multi-user.target

  

 
查看服务状态
 
systemctl daemon-reload
systemctl restart webssh
systemctl status webssh 

 

 
3、nginx添加反向代理(/etc/nginx/conf.d)
 
conf.d]# cat webssh.conf 
server {
    listen 8888;
    root /var/www/html;

    location / {
        proxy_pass http://127.0.0.1:6666;
        proxy_http_version 1.1;
        proxy_read_timeout 300;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Real-PORT $remote_port;
    }

}

 

 
index.html路径
/usr/local/share/python3/lib/python3.10/site-packages/webssh/templates

 

解决报错libssl.so.1.1: cannot open shared object file: No such file or directory
#从官网下载
# wget https://www.openssl.org/source/openssl-1.1.1e.tar.gz

#腾讯云提供的镜像
wget https://mirrors.cloud.tencent.com/openssl/source/openssl-1.1.1e.tar.gz

tar -xvf openssl-1.1.1e.tar.gz
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
make && make install

echo "/usr/local/lib64/" >> /etc/ld.so.conf
ldconfig

#验证版本
openssl version

 

 
 
 

posted on 2022-11-25 14:36  mrqiao001  阅读(311)  评论(0编辑  收藏  举报