【问题标题】:Nginx fancy-index header and footer never loadNginx 花式索引页眉和页脚从不加载
【发布时间】:2022-01-16 12:27:45
【问题描述】:

我正在创建一个 Nginx 文件服务器,并且我正在尝试启用 fancy-index 模块以获得自定义页眉和页脚,但我无法让它工作,页眉/页脚永远不会加载。 (请求甚至没有从浏览器完成)。

目前,我已经学习了本教程:https://neilmenon.com/blog/install-nginx-fancyindex

我当前的网站配置是

server {
        listen  80;

        server_name myname;

        autoindex on;
        autoindex_exact_size    off;    
        autoindex_localtime     on;     
        location / {                    
                root /var/www/html
                fancyindex on;
                fancyindex_exact_size off;
                fancyindex_footer /fancy-index/footer.html;
                fancyindex_header /fancy-index/header.html;
                fancyindex_css_href /fancy-index/style.css;
                fancyindex_time_format "%B %e, %Y";
        }
}

我还在文件第一行的 nginx.conf 中加载了模块

load_module /usr/share/nginx/modules/ngx_http_fancyindex_module.so;

我还澄清说我是 nginx 新手,所以如果这是我应该注意的常见问题,我深表歉意。

提前致谢,任何帮助将不胜感激

【问题讨论】:

    标签: nginx module


    【解决方案1】:

    我无法找到使用花式索引的解决方案,但是,我有一个解决方法,即使用花式索引所基于的模块 ngx_http_addition_module。

    这个模块在这里:https://nginx.org/en/docs/http/ngx_http_addition_module.html

    基本上,配置如下:

     location / {                    
                    root /var/www/html
    
                    addition_types text/html;                  # Replace this with watever mime type this server is responding
                    add_before_body /fancy-index/header.html;  # Replace the fancyindex_header 
                    add_after_body /fancy-index/footer.html;   # Replace the fancyindex_footer 
            }
    

    您无法从这些指令链接样式表或更改时间格式,但没有什么可以阻止从标题加载样式表并在其中添加脚本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-08
      • 1970-01-01
      • 1970-01-01
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      相关资源
      最近更新 更多