stm32 esp8266 ota系列文章:
stm32 esp8266 ota-快速搭建web服务器之docker安装openresty
stm32 esp8266 ota升级-tcp模拟http
stm32 esp8266 ota升级-hex合并-烧录-bin生成
stm32 esp8266 ota升级-qt bin文件处理工具
stm32 esp8266 ota升级-自建mqtt和文件服务器动态AB面方式
stm32 esp8266 ota升级-自建mqtt和文件服务器全量升级
stm32 esp8266 ota-快速搭建web服务器之docker安装openresty
文章目录
介绍
OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。
快速构造出足以胜任 10K 乃至 1000K 以上单机并发连接的高性能 Web 应用系统。
具体详细介绍请参阅官网 http://openresty.org/cn/
安装(提前安装好docker)
docker pull openresty/openresty
拷贝和修改配置
先任何配置启动,后期删除,再按照所需启动,这里仅仅为了拷贝配置
docker run -itd --name openresty -p 51802:80 openresty/openresty # 定义名字,方便后边操作
新建目录
mkdir -p /home/openresty/conf/
拷贝
格式:docker cp CONTAINER:SRC_PATH DEST_PATH
docker cp openresty:/usr/local/openresty/nginx/conf/nginx.conf /home/openresty/conf/
docker cp openresty:/etc/nginx/conf.d/default.conf /home/openresty/conf/
docker cp openresty:/usr/local/openresty/nginx/html/ /home/openresty/
修改
编辑nginx配置给root权限
user root;
worker_processes 1;
编辑default.conf
server {
listen 80;
server_name *.*;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /hello {
content_by_lua_block {
ngx.say("<p>hello, world</p>")
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/openresty/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root /usr/local/openresty/nginx/html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
删除为了拷贝启动的临时容器
docker rm -f openresty #根据名字删除
启动容器
docker run -itd --name openresty -v /home/openresty/conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf:rw -v /home/openresty/conf/default.conf:/etc/nginx/conf.d/default.conf:rw -v /home/openresty/html:/usr/local/openresty/nginx/html:rw -p 51802:80 openresty/openresty
宿主机目录:/home/openresty/conf/
需要挂载的目录:/usr/local/openresty/nginx/conf/ /etc/nginx/conf.d/
测试
浏览器输入 http://域名或ip+端口号
访问http://alyou.langtaotech.cn:51802/1.txt ,对比:文件服务器中1.txt文件内容与http获取内容一致