杜郎俊赏 - dujun.io

开源实例之Expose

前言

本篇介绍使用 Expose 实现内网穿透。了解什么是内网穿透可以参考《开源实例之frp》一文中的介绍。

Expose 介绍

Expose is a tunnel application that allows you to share your local sites and applications with others on the internet. It is open source, written in PHP and the best alternative to ngrok for PHP developers.

Expose 用 PHP 语言编写,功能与 ngrok 类似。

仓库地址:https://github.com/beyondcode/expose
官网地址:https://expose.dev

Expose 部署

环境安装

需要先安装 PHP 8.1+ 环境,以 Debian 11 为例:

curl -sSL https://packages.sury.org/php/README.txt | bash -x
apt install php8.1 php8.1-mbstring php8.1-sqlite3 -y

软件安装

安装 Expose 有三种方式:

PHAR 安装

wget https://github.com/beyondcode/expose/raw/master/builds/expose
mv expose /usr/bin/
chmod +x /usr/bin/expose

Composer 安装

composer global require beyondcode/expose

增加环境变量:

export PATH=~/.composer/vendor/bin:$PATH

Docker 部署

克隆仓库后构建镜像:

docker build -t expose .

启动容器:

docker run expose <expose command>

软件使用

自建服务端

启动服务端(公网服务器):

expose serve expose.local

访问 http://expose.local:8080 即可进入后台,初始用户名/密码就是 username/password。

创建用户并拿到 token。

官方服务端

官方提供公共服务端,与 ngrok 类似,优势是允许自定义域名。

在官网注册账号,登录后拿到 token 即可。

启动客户端

#设置 token
expose token ****

#开启映射
expose share http://local --subdomain=dujun

如图所示,通过公网 http://dujun.sharedwithexpose.com 就能访问本地 http://local。

后记

体验更多开源实例

标签: 开源实例
日期:2023-02-27