nginx 搭建靜態文件服務器

話不多說直接上conf文件

 


#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    server {
        listen  80;
        server_name  localhost;
        charset utf-8;
        autoindex on;
        
        location /file/ {
        alias   D:/nginxShare/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        }
    }
    
    server {
    listen 8001;
    server_name localhost;

    # root 不會吞掉 location 已經匹配的路徑, 如:
    # localhost:8001/html/a -> D:/ngxin/html/a
    location /html {
        root   html;
        index  index.html index.htm;
    }

    # alias  會吞掉 location 已經匹配的路徑, 如:
    # localhost:8001/imgs/a.jpg -> D:/ngxin/imgs/a.jpg
    location /imgs/ {
        alias   D:/nginxShare/imgs/;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
        }
    }
}
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章