話不多說直接上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;
}
}
}