stm32 esp8266 ota-快速搭建web服务器之docker安装openresty

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/

image-20221207135540845

image-20221207135426903

修改

编辑nginx配置给root权限
user  root;
worker_processes 1;

image-20221207135658324

编辑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+端口号

image-20221207140045176

访问http://alyou.langtaotech.cn:51802/1.txt ,对比:文件服务器中1.txt文件内容与http获取内容一致

image-20221223180843918

image-20221223180925078

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心之雅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值