【Nginx】使用nginx搭建文件服务镜像站

talk is cheap, show me the code.

  • 搭建环境

    K V
    OS Windows 7
    nginx 1.14.2

nginx.conf

worker_processes  1;
error_log logs/error.log;

events {
    worker_connections  1024;
}

# 是否设置后台运行默认是on后台运行!:
daemon on;

http {
	# windows使用的gbk格式的文件编码,而Linux系统中支持中文的编码则是utf-8.所以为了在windows下面支持文件名中文的正常显示(注意先后顺序)
	charset gbk,utf-8;
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

	# log_format  main  'remote_addr=$remote_addr:$remote_port, http_x_forwarded_for=$http_x_forwarded_for, proxy_add_x_forwarded_for=$proxy_add_x_forwarded_for ';
    access_log  logs/access_format.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on
	
	##############文件服务器配置##############
	# 显示目录
	autoindex on;
	# 关闭文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)
	autoindex_exact_size off;
	# 显示文件时间
	autoindex_localtime on;

	server {
		listen       80;
        server_name  localhost;
        # 指定挂载根目录
		root         E:/share-data/;
		
		location / {
		}
		
		error_page 404 /404.html;
			location = /40x.html {
		}
		
		error_page 500 502 503 504 /50x.html;
			location = /50x.html {
		}
	}
	
}

访问 http://localhost
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/AV_woaijava/article/details/106215068