ngrok
使用
进入ngrok的exe文件所在的目录,使用“ngrok http [port]”启动端口映射。本地django项目默认使用8000端口,所以输入如下命令即可
ngrok http 8000
解决方案
问题:错误 Invalid Host header
原因:vue cli3 。新版的webpack-dev-server 出于安全考虑,默认检查 hostname,如果hostname不是配置内的,将中断访问。
解决:在配置文件中新增配置
//vue.config.js
module.exports = {
devServer: {
disableHostCheck: true
},
};
其他版本解决
webpack.dev.conf.js添加配置 disableHostCheck: true,
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
},
disableHostCheck: true, //新增
},
在服务器上部署使用
https://zhuanlan.zhihu.com/p/49192702
钉钉内网穿透
文档
https://developers.dingtalk.com/document/resourcedownload/http-intranet-penetration
使用
1.下载工具
git clone https://github.com/open-dingtalk/pierced.git
2.启动
windows 执行以下命令
cd windows_64
ding -config=ding.cfg -subdomain=abcde 8080
- 参数说明: | 参数 | 说明 | | —- | —- | | -config | 内网穿透的配置文件,按照命令示例固定为钉钉提供的./ding.cfg,无需修改 | | -subdomain | 您需要使用的域名前缀,该前缀将会匹配到“vaiwan.com”前面,例如你的subdomain是abcde,启动工具后会将abcde.vaiwan.com映射到本地。 | | 端口 | 您需要代理的本地服务http-server端口,例如你本地端口为8080等 |
启动完客户端后,你访问http://abcde.vaiwan.com/xxxxx都会映射到 http://127.0.0.1:8080/xxxxx。
**注意
- 需要访问的域名是http://abcde.vaiwan.com/xxxxx 而不是http://abcde.vaiwan.com:8080/xxxxx
- 启动命令的subdomain参数有可能被别人占用,尽量不要用常用字符,可以用自己公司名的拼音,例如:alibaba、dingding等。
- 可以在本地起个http-server服务,放置一个index.html文件,然后访问http://abcde.vaiwan.com/index.html测试一下。
备注:不要使用常用的字符。可能会被占用
https://segmentfault.com/a/1190000038658138
https://github.com/fatedier/frp/blob/dev/README_zh.md
钉钉
https://developers.dingtalk.com/document/resourcedownload/http-intranet-penetration
ngrok
https://ngrok.com/download
https://segmentfault.com/a/1190000018990329
frp相关
https://juejin.cn/post/6844904191681380360
123.207.97.144