Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure using index directory under Nginx server

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to configure the index directory under the Nginx server". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Nginx configuration

Location ~ ^ / 2589 (/. *) {autoindex on;// enable autoindex_localtime on;// to enable display function}

Auto_index instruction

Syntax: autoindex on | off

Configuration segment: autoindex off

Configuration segment: http, server, location

Enable / use nginx catalog indexing only.

Syntax: autoindex_exact_size on | off

Configuration segment: autoindex_exact_size on

Configuration segment: http, server, location

Determine whether to display the file size in bytes, mb,gb, etc. The default is to open

Syntax: autoindex_localtime on | off

Configuration segment: autoindex_localtime off

Configuration segment: http, server, location

Specifies the time it takes to display directories or files, which is not displayed by default.

Nginx+fancy implements a beautiful index directory

Nginx index directory comes with a very simple function, and not good-looking, how to make a beautiful index list. Let's take a look.

Installation environment

System: centos 6.3nginx:1.4.2

Fancy: http://wiki.nginx.org/ngxfancyindex

Download and install fancy

Compare the built-in index effect of nginx (the picture posted in the previous article) as follows

# wget http://gitorious.org/ngx-fancyindex/ngx-fancyindex/archive-tarball/master# tar-xzvf master# wget http://nginx.org/download/nginx-1.4.2.tar.gz# tar-xzvf nginx-1.4.2.tar.gz# cd nginx-1.4.2#. / configure-- prefix=/usr/local/nginx-1.4.2-- add-module=../ngx-fancyindex-ngx-fancyindex# make# make install

Fancy Index configuration

Server {listen 80; server_name test.jb51.net; access_log / data/logs/nginx/test.jb51.net.access.log main;index index.html index.php index.html; root / data/site/test.jb51.net;location / {} location ~ ^ / 2589 (/. *) {fancyindex on; fancyindex_exact_size off; fancyindex_localtime on; fancyindex_footer "myfooter.shtml";}}

Look at the effect of adding fancy to nginx, as shown below.

It's hard to say how much better than the one you brought with you. Anyway, it is. It looks a little better.

Parameter explanation:

Fancyindex on: open the fancy index

Fancyindex_exact_size off: do not use exact size, use rounding, 1.9m will be displayed as 2m like this. If enabled, the unit is in bytes

Fancyindex_localtime on: use local time

Fancyindex_footer "myfooter.shtml": take the myfooter.shtml content under the current path as the bottom. If the file does not exist, 404 will appear at the bottom.

The myfooter.shtml content is as follows:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report