在Hugging Face上部署WebSSH

作者项目:

由于作者项目中没有加入utf-8导致中文乱码,所以使用了我的小号添加了utf-8
Dockerfile代码

FROM python:3-alpine
LABEL maintainer='<author>'
LABEL version='0.0.0-dev.0-build.0'

# Install necessary packages
RUN apk add --no-cache \
    libc-dev \
    libffi-dev \
    gcc \
    wget \
    unzip

# Download and unzip the GitHub repository
RUN set -e; \
    DOWNLOAD_URL="https://github.com/taito001/huashengdun-webssh/archive/refs/heads/master.zip"; \
    echo "Downloading from: $DOWNLOAD_URL"; \
    wget "$DOWNLOAD_URL" -O /tmp/webssh.zip || (echo "Download failed. URL may be incorrect." && exit 1); \
    unzip /tmp/webssh.zip -d /tmp && \
    mv /tmp/huashengdun-webssh-master /code && \
    rm /tmp/webssh.zip

WORKDIR /code

# Install Python dependencies
RUN pip install -r requirements.txt --no-cache-dir

# Remove unnecessary packages
RUN apk del gcc libc-dev libffi-dev wget unzip

# Set up user and permissions
RUN addgroup webssh && \
    adduser -Ss /bin/false -g webssh webssh && \
    chown -R webssh:webssh /code

EXPOSE 8888/tcp

USER webssh

# Modify the CMD instruction to use an array format
CMD ["python", "run.py"]

由于反代存在着头部问题,我修改后出现未授权问题,所以选择了在cloudflare进行重定向

export default {
  async fetch(request, env, ctx) {
    // 获取原始请求的 URL
    const url = new URL(request.url);
    
    // 构建新的 URL,保持原始路径和查询参数
    const newUrl = new URL(url.pathname + url.search, 'https://xxxxx.hf.space');
    
    // 创建重定向响应
    return Response.redirect(newUrl.toString(), 301);
  }
}

https://xxxxx.hf.space换为自己的huggingface域名

由于Hugging Face不支持IPV6,无法用于连接纯IPV6的VPS,适用于IPV4小鸡或Serv00被墙时使用,需要IPV6环境可以参考

12 个赞

感谢分享 :tieba_013:
同在抱脸部署过这个,不过用不上就删了 :joy:

4 个赞

感谢分享

4 个赞

WebSSH在某些时候能够救急。不过这两天s6.serv00.com可以正常访问了,但是速度还是很卡。

2 个赞

太强了佬

1 个赞

mark

前两天s6的问题,开了魔法也卡