我正在創建一個 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 的新手,所以如果這是我應該注意的常見問題,我深表歉意。
提前致謝,任何幫助將不勝感激
uj5u.com熱心網友回復:
我無法找到使用花式索引的解決方案,但是,通過使用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
}
您無法從這些指令鏈接樣式表或更改時間格式,但沒有什么可以阻止從標題加載樣式表并在其中添加腳本的時間。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/386050.html
