nginx正则测试工具
整理了一些方便nginx 正则测试的工具
使用官方提供的一个基于php 的环境
nginx-regex-tester
使用pcretest
对于alpine docker 镜像可以通过安装pcre-tools 解决
参考集成环境
nginx-regex-tester我已经构建过一个docker镜像,以下是pcretest的
- dockerfile
FROM nginx:alpine
LABEL author="dalongrong"
RUN set -x \
&& /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories \
&& apk update && apk add --no-cache pcre-tools
COPY --from=yaronpr/gotty /usr/local/bin/gotty /usr/local/bin/gotty
EXPOSE 8080
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
entrypoint.sh
#!/bin/sh
nohup gotty -w sh &
nginx -g "daemon off;"
pcretest 简单说明
第一行写 /中间加上正则表达式/
第二行写 要匹配的字符
结果说明:
0表示匹配到的所有内容
1最后表示每个位置匹配到的内容
集成环境docker-compose
- docker-compose 文件
version: "3"
services:
nginx-test:
build: ./
image: dalongrong/nginx-pcretest
ports:
- "80:80"
nginx-regex-test:
image: dalongrong/nginx-regex-tester_regextester:latest
ports:
- "8080:80"
- 使用
nginx-regex-tester http://localhost:8080/regextester.php
pcretest http://localhost:9090 (webconsole 操作)
golang supervisord 版本的pcretest dockerfile
FROM nginx:alpine
LABEL author="dalongrong"
RUN set -x \
&& /bin/sed -i 's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' /etc/apk/repositories \
&& apk update && apk add --no-cache pcre-tools
COPY --from=yaronpr/gotty /usr/local/bin/gotty /usr/local/bin/gotty
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
EXPOSE 8080 80
COPY supervisor.conf /etc/supervisor.conf
CMD ["/usr/local/bin/supervisord","-c","/etc/supervisor.conf"]
supervisor.conf
[program:website]
command = nginx -g "daemon off;"
[inet_http_server]
port = :9001
[program:gotty]
command = gotty -w sh
说明
以上运行集成了gotty一个很不错的webconsole 工具,对于开发环境还是很不错的选择,可以方便测试,同时我也已经制作了
一个集成好的docker镜像dalongrong/nginx-pcretest
可以方便使用
参考资料
https://www.cnblogs.com/rongfengliang/p/13150534.html
https://github.com/nginxinc/NGINX-Demos/tree/master/nginx-regex-tester
https://github.com/yudai/gotty
https://github.com/rongfengliang/nginx-pcretest-docker
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2018-12-11 Gource 方便的软件版本可视化录制工具
2018-12-11 tailor multi fragment && cutom-amd script demo 说明
2018-12-11 使用tailor 轻松方便的集成web 框架react&&vue
2017-12-11 apache phoenix 安装试用