1、location / + 目录或者文件
location /list {
alias /usr/share/nginx/html/list;
autoindex on;
}
location /cxd.txt {
alias /usr/share/nginx/html/cxd.txt;
autoindex on;
}
如下:
2、多域名
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name cc.abxt.com;
location / {
autoindex on;
root /mnt/media/mnt;
index index.html index.htm;
}
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80;
server_name hello.abxt.com;
#root /usr/share/nginx/html;
location / {
autoindex on;
root /usr/share/nginx/html;
}
}
}