当前位置:网站首页>pm2 static file service
pm2 static file service
2022-08-10 14:54:00 【choukin】
Respect individual survival experience,Connect independent thinking ability,Bridging the boundaries between knowledge and ability ———— 《我的二本学生》
通过 http The protocol serves static files
PM2 可以通过命令 pm2 serve
Enable the static file serving function.It supports access to multiple raw files provided in a specified folder,Or as a single page application.
CLI
使用简单的命令,通过httpto serve static files(like a front-end app)
pm2 serve <path> <port>
默认端口是8080
如果没有指定<path>
The current folder will be used.It can also be used like any other app--name
或者 --watch
单页面应用:All requests are redirected to index.html
使用--spa
option to redirect all requests to index.html
pm2 serve --spa
使用配置文件
// ecosystem.config.js
module.exports = {
apps : [{
script:"serve",
env:{
PM2_SERVE_PATH:'.',
PM2_SERVE_PORT:8080,
PM2_SERVE_SPA: true,
PM2_SERVE_HOMEPAGE:'./index.html',
}
}]
}
Execute the following command and access http://localhost:8080
pm2 start ecosystem.config.js
Access rights are set by using a password
To protect access to public files you can use the following command
pm2 serve --basic-auth-username <username> --basic-auth-password <password>
配置文件方式
// ecosystem.config.js
module.exports = {
script:"serve",
env:{
PM2_SERVE_PATH:'.',
PM2_SERVE_PORT:8080,
PM2_SERVE_SPA:'./index.html',
PM2_SERVE_BASIC_AUTH: 'true',
PM2_SERVE_BASIC_AUTH_USERNAME: 'example-login',
PM2_SERVE_BASIC_AUTH_PASSWORD: 'example-password'
}
}
边栏推荐
猜你喜欢
中学数学建模书籍及相关的视频等(2022.08.09)
DB2查询2个时间段之间的所有月份,DB2查询2个时间段之间的所有日期
Mysql语句分析、存储引擎、索引优化等详情
基于 Azuki 系列:NFT估值分析框架“DRIC”
List集合
蓝帽杯半决赛火炬木wp
2022年网络安全培训火了,缺口达95%,揭开网络安全岗位神秘面纱
【有限元分析】异型密封圈计算泄漏量与参数化优化过程(带分析源文件)
面试面到了一个腾讯30k出来的,有见识到何为精通MySQL调优
Analysys and the Alliance of Small and Medium Banks jointly released the Hainan Digital Economy Index, so stay tuned!
随机推荐
websocket实现实时变化图表内容
物资采购小程序开发制作功能介绍
“国资云”和“国家云”能给市场带来怎样的变革?
Summary of Force Buckle Solution 640 - Solving Equations
自定义picker滚动选择器样式
舵机内部结及工作原理浅析[通俗易懂]
安装mysql报错处理
兆骑科创高层次人才创业大赛平台,投融资对接,双创服务
解题-->在线OJ(十九)
1004(树状数组+离线操作+离散化)
Go Context基本使用
file system design
WSL 提示音关闭
程序员=加班??——掌握时间才能掌握人生
【吴恩达来信】强化学习的发展!
Digital Collection Platform System Development Practice
Azure IoT 合作伙伴技术赋能工作坊:IoT Dev Hack
从洞察到决策,一文解读标签画像体系建设方法论
Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
Mysql语句分析、存储引擎、索引优化等详情