NOTE

1.3 File Server

A simple Nginx file server using autoindex.

Web Servers / NginxCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. Configuration

  • /etc/nginx/nginx.conf
http {
    #...
    include /etc/nginx/conf.d/*.conf;
    #...
}
  • /etc/nginx/conf.d/cdn.conf
autoindex on;             # Enable the index function
autoindex_exact_size off; # Disable calculation of the exact file size in bytes and show an approximate size in KB, MB, or GB
autoindex_localtime on;   # Display local time instead of GMT
charset utf-8; # Avoid garbled Chinese characters

server {
	listen       9999; # Listening port
	# server_name  localhost;
	#root         /usr/share/nginx/html;
	root         <USER_HOME>/share; # Shared file directory
	error_log <USER_HOME>/share/log/error.log ; # Error log directory

	location / {
	}

	error_page 404 /404.html;
	location = /40x.html {
	}

	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
	}
}

2. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub