nginx configuration
location ~ ^/2589(/.*) { autoindex on; //开启 autoindex_localtime on;//开启显示功能 }
auto_index directive
Syntax: autoindex on | off;
Configuration section: autoindex off;
Configuration section: http, server, location
Enable/only use nginx directory indexing function.
Syntax: autoindex_exact_size on | off;
Configuration section: autoindex_exact_size on;
Configuration section: http, server, location
Determine whether to additionally display the size of the file, in bytes, mb, gb, etc. The default is to open
syntax: autoindex_localtime on | off;
Configuration section: autoindex_localtime off;
Configuration section: http, server, location
Specify whether to display the directory or file time. The default is not to display.
nginx fancy implements a beautiful index directory
nginx index directory has its own functions that are very simple and not good-looking. How to make a beautiful index list. Let’s see next .
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 (Picture posted in the previous article), as shown below
# 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.
How much better it looks than the one that comes with it, it’s hard to say... Anyway, it just makes it look better~
Parameter explanation:
fancyindex on: Turn on fancy index
fancyindex_exact_size off: Do not use the exact size, use rounding, 1.9m will be displayed as 2m. If it is turned on, the unit is bytes
fancyindex_localtime on: Use local time
fancyindex_footer "myfooter.shtml": Use the content of myfooter.shtml in the current path as the bottom. If the file does not exist, 404 will appear at the bottom.
The content of myfooter.shtml is as follows:
<!-- footer start --> <div id="footer"> <a id="gotop" href="#" onclick="mgjs.gotop();return false;">回到顶部</a> <a id="powered" href="http://wordpress.org/">wordpress</a> <div id="copyright"> 版权所有 © 2006-2015 本站 </div> <div id="themeinfo"> <a href="//www.jb51.net/about/">关于我们</a> | <a href="//www.jb51.net/sitemap.html">网站导航</a> | <a href="//www.jb51.net/sitemap.xml">网站地图</a> |<a rel="nofollow" href="http://www.miibeian.gov.cn/">苏icp备14036222号</a> </div> </div> <!-- footer end --> fancy指令使用:
fancyindex
Syntax:
*fancyindex* [*on* | *off*]
Default value: fancyindex off
Configuration block: http, server, location
Description: Turn on/off the directory index function
fancyindex_css_href
Syntax:
*fancyindex_css_href uri*
Default value: fancyindex_css_href ""
Configuration block: http, server, location
Description: External css path, this css will replace the existing css style. If you know CSS, you can make the index list more beautiful. We don’t have a web designer in ttlsa, so we can only use the one that comes with it ^^
fancyindex_exact_size
Syntax:
*fancyindex_exact_size* [*on* | *off*]
Default Value: fancyindex_exact_size on
Configuration block: http, server, location
Description: Define how to display the size of the file, the default is on, on: use the exact value of the file size, the unit is bytes. off: the unit is kb, mb, gb, if they contain a decimal point, they will be rounded. For example, 1.9mb will be displayed as 2mb.
fancyindex_footer
Syntax:
*fancyindex_footer path*
Default value: fancyindex_footer ""
Configuration block: http, server, location
Description: Specify which file to embed at the bottom of the index page, please see the effect See the first picture of this article
fancyindex_header
Syntax:
*fancyindex_header path*
Default value: fancyindex_header ""
Configuration block: http, server, location
Description: Specify which file to embed in Header of the index page. Usage is similar to fancyindex_footer
fancyindex_ignore
Syntax:
*fancyindex_ignore string1 [string2 [... stringn]]*
Default value: no default.
Configuration block: http, server, location
Description: Which files / directory is hidden. If your nginx supports regular expressions, you can use regular expressions to filter
For example, I want to hide the files or directories starting with dir and the file filea.txt. The configuration is as follows:
fancyindex_ignore "dir*" "filea.txt"
fancyindex_localtime
Syntax:
*fancyindex_localtime* [*on* | *off*]
Default value: fancyindex_localtime off
Configuration block: http, server, location
The above is the detailed content of How to configure and use the index directory under Nginx server. For more information, please follow other related articles on the PHP Chinese website!

NGINXUnit simplifies application deployment with dynamic configuration and multilingual support. 1) Dynamic configuration can be modified without restarting the server. 2) Supports multiple programming languages, such as Python, PHP, and Java. 3) Adopt asynchronous non-blocking I/O model to improve high concurrency processing performance.

NGINX initially solved the C10K problem and has now developed into an all-rounder who handles load balancing, reverse proxying and API gateways. 1) It is well-known for event-driven and non-blocking architectures and is suitable for high concurrency. 2) NGINX can be used as an HTTP and reverse proxy server, supporting IMAP/POP3. 3) Its working principle is based on event-driven and asynchronous I/O models, improving performance. 4) Basic usage includes configuring virtual hosts and load balancing, and advanced usage involves complex load balancing and caching strategies. 5) Common errors include configuration syntax errors and permission issues, and debugging skills include using nginx-t command and stub_status module. 6) Performance optimization suggestions include adjusting worker parameters, using gzip compression and

Diagnosis and solutions for common errors of Nginx include: 1. View log files, 2. Adjust configuration files, 3. Optimize performance. By analyzing logs, adjusting timeout settings and optimizing cache and load balancing, errors such as 404, 502, 504 can be effectively resolved to improve website stability and performance.

NGINXUnitischosenfordeployingapplicationsduetoitsflexibility,easeofuse,andabilitytohandledynamicapplications.1)ItsupportsmultipleprogramminglanguageslikePython,PHP,Node.js,andJava.2)Itallowsdynamicreconfigurationwithoutdowntime.3)ItusesJSONforconfigu

NGINX can be used to serve files and manage traffic. 1) Configure NGINX service static files: define the listening port and file directory. 2) Implement load balancing and traffic management: Use upstream module and cache policies to optimize performance.

NGINX is suitable for handling high concurrency and static content, while Apache is suitable for dynamic content and complex URL rewrites. 1.NGINX adopts an event-driven model, suitable for high concurrency. 2. Apache uses process or thread model, which is suitable for dynamic content. 3. NGINX configuration is simple, Apache configuration is complex but more flexible.

NGINX and Apache each have their own advantages, and the choice depends on the specific needs. 1.NGINX is suitable for high concurrency, with simple deployment, and configuration examples include virtual hosts and reverse proxy. 2. Apache is suitable for complex configurations and is equally simple to deploy. Configuration examples include virtual hosts and URL rewrites.

The purpose of NGINXUnit is to simplify the deployment and management of web applications. Its advantages include: 1) Supports multiple programming languages, such as Python, PHP, Go, Java and Node.js; 2) Provides dynamic configuration and automatic reloading functions; 3) manages application lifecycle through a unified API; 4) Adopt an asynchronous I/O model to support high concurrency and load balancing.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor
