exposedjs
[TOC]
包
包名称:exposedjs(暴露)
包版本:0.7.5(测试版)
包功能:类似与内网穿透。
包依赖:socket.io
为什么要使用exposedjs?
开发者想要把内网的服务器的资源映射到公网上去,开发者拥有一台公网的服务器。通过socketio建立双向通信,让后进行接口的转发,目前只能一对一映射,后面会映射多个内网服务器。
目录结构
exposedjs
|PrimaryServer.js——主服务(公网用)
|FollowServer.js——从服务(内网用)
怎么使用exposedjs?
一、准备
- 一台公网服务器
- 一台内网服务器
二、下载引入
npm i -S exposedjs//下载包const exp = ;//引入主服务包 const exp = ; //引入从服务包
三、公网服务器代码
const express = ;const exp = ; let app = ;//如果填写了这个配置自动更改为https// exp.config(,'sslPath',{// key:"./ssl/xxx",// cert:"./ssl/xx"// })exp; //限制访问为100 默认10exp//该应用的pm2 id , id默认为0exp;//实例化app,启动映射服务,监听8000端口
四、内网服务器代码
const exp = ; exp; expmethod"/sum1""get"{ //query:ajax data传值 let sum = reqquerya+reqqueryb; res ;//0.3.0修改 //响应数据,返回到浏览器}; exp;//同步
浏览器代码
let data = a: Math b: Math ;console; $;
版本信息
0.7.0
增加https
0.6.1
修改若干bug
0.6.0
增加自动重启服务功能。(需要mp2支持)
增加简单的cookie功能。
0.4.0
优化服务器之间的传值对象,修改响应数据方式。(return {返回值} 修改为 res.send(返回值))
支持访问限制
0.3.0
实现大多数功能,修复大多数bug