当前位置:网站首页>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
使用--spaoption 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'
}
}
边栏推荐
- usb转rs485测试软件,usb转rs485「建议收藏」
- MySQL advanced (thirty-three) MySQL data table adding fields
- 1W字详解线程本地存储 ThreadLocal
- How does IT Xiaobai learn PHP systematically
- Second half of 2011 System Architect Afternoon Paper II
- 奢侈品鉴定机构小程序开发制作功能介绍
- 司空见惯 - 股市狠狠下跌后,何時能反弹?
- 使用Uiautomator2进行APP自动化测试
- laravel throws the error to Dingding
- Lack of comparators, op amps come to the rescue!(Op amp is recorded as a comparator circuit)
猜你喜欢

Unfinished mathematics test paper ----- test paper generator (Qt includes source code)

易观分析联合中小银行联盟发布海南数字经济指数,敬请期待!

符合信创要求的堡垒机有哪些?支持哪些系统?

Flask框架——MongoEngine使用MongoDB数据库

fatal error C1083 无法打开包括文件'io.h' No such file

PyTorch 多机多卡训练:DDP 实战与技巧

统信 UOS V20 专业版(1050update2)发布:文件共享、全局搜索等优化

蓝帽杯半决赛火炬木wp

使用决策树对鸢尾花进行分类

第五讲 测试技术与用例设计
随机推荐
12海里、24海里、200海里的意义及名称
【剑指offer】---数组中的重复数字
tensorflow安装踩坑总结
Appium进行APP自动化测试
IT小白怎么系统的php学习
High-paid programmers & interview questions series 135 How do you understand distributed?Do you know CAP theory?
紫金示例
PEST 分析法
DB2查询2个时间段之间的所有月份,DB2查询2个时间段之间的所有日期
Do not access Object.prototype method ‘hasOwnProperty‘ from target object....
mysql进阶(三十三)MySQL数据表添加字段
SQL学习(基础)
2011年下半年 系统架构设计师 下午试卷 II
@RequestBody的使用[通俗易懂]
MQTT服务器搭建
物资采购小程序开发制作功能介绍
无线网络、HTTP缓存、IPv6
TestLink导出用例转换工具
1004(树状数组+离线操作+离散化)
XML基本学习