nginx-echo模块安装

1. 介绍

在nginx默认中,是没有echo模块的,在nginx.conf文件中存在echo会报错,需要安装echo模块。
image

2. 下载echo-nginx模块

下载链接:https://github.com/openresty/echo-nginx-module/
image
将下载的tar.gz压缩包解压

cd /data/nginx-1.22.0
./configure --prefix=/data/nginx --add-module=/data/echo-nginx-module-0.62
# make upgrade    #平滑升级,还是会提示文件中存在echo,这种猜测应该是已经正常运行的nginx,然后升级之后,在配置echo等信息
make install        #全新安装

image
说明,当将echo取消注释的时候,访问一些xxx.apk等不存在的文件时,会提示进行下载,下载的是一个文本文件,且里面的内容就是echo的输出内容,当把这些echo注释之后,就不会出现这个问题,没有找到资源就是404;uri是你请求的资源路径(不含协议和主机以及查询参数);
针对首页:可以进行形如下面的配置:

location / {
    root   html;
    index  index.html index.htm;
    # 当没有填写资源路径的时候,自动跳转到指定的主页上去(浏览器重定向)
    if ($uri = "/") {
        rewrite / /common/index.html permanent;
    }
}
posted @ 2022-07-21 08:41  理舞  阅读(723)  评论(0编辑  收藏  举报