我已经禁用了这样的目录列表......
Options -Indexes
Run Code Online (Sandbox Code Playgroud)
当我尝试访问这样的目录时:-
www.example.com/secret/
Run Code Online (Sandbox Code Playgroud)
我收到403 Forbidden响应。
但是,我想要一个404 Not Found响应,所以黑客无法轻易猜出我的目录结构。我该怎么做?
背景:我在 CentOS 5.3 上运行 lighttpd 1.4.28-1 来为静态资产提供服务。
信号:最近,有时会变慢。我在内核日志中收到以下错误,并且/var/log/messages:
proftpd[5145]: (::ffff:xx[::ffff:xx]) - FTP session opened.
proftpd[5145]: (::ffff:xx[::ffff:xx]) - Preparing to chroot to directory 'xx'
EXT3-fs warning (device dm-3): ext3_dx_add_entry: Directory index full!
Sep 16 15:30:34 xx last message repeated 489 times
Run Code Online (Sandbox Code Playgroud)
inode信息:
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/ddf1_p3
77037568 9996012 67041556 13% /
/dev/mapper/ddf1_p1
26104 35 26069 1% /boot
tmpfs 505834 1 505833 1% /dev/shm
Run Code Online (Sandbox Code Playgroud)
文件系统的内容:
tune2fs 1.39 (29-May-2006)
Filesystem volume name: / …Run Code Online (Sandbox Code Playgroud) 我已经设置了一个虚拟主机,它指定了在调用 URL 时要加载的默认文件。
我遇到的问题是我需要该默认 DirectoryIndex 文件出现在 URL 中。
因此,当我访问:www.mysite.co.uk 时,我希望 www.mysite.co.uk/app.php 出现在 URL 中。
如何使用我的 apache.conf 文件中的虚拟主机配置来实现这一点?
这是我当前的代码:
<VirtualHost *:80>
ServerName *.mysite.co.uk
DocumentRoot "/var/www/html/mysite/web/"
DirectoryIndex app.php
</VirtualHost>
Run Code Online (Sandbox Code Playgroud) 我试图让 nginx 忽略index.html文件并始终显示模块中的目录列表autoindex。
如果我删除我的index行,nginx 仍然默认提供index.html文件,所以这不是一个解决方案。
Stack Overflow 上也提出了类似的问题,但我正在寻找一种不涉及发明虚假文件名的解决方案,如果存在这样的解决方案(更不用说该线程在那里偏离主题)。
如何更改index指令以告诉 nginx 从不显示索引文件?
我有以下服务器配置:
server {
listen 80;
server_name _;
root /var/www/;
location /calendars/ {
autoindex on;
try_files $uri.ics $uri =404;
}
}
Run Code Online (Sandbox Code Playgroud)
如果希望autoindex在访问时获得页面http://example.com/calendars/,但是我得到一个404 File not found错误。
我希望服务器做这样的伪代码:
if($uri is directory) {
if(one of index pages exists in directory) {
show index page;
} else {
show autoindex page;
}
} else {
if($uri.ics exists) {
show $uri.ics;
} else if($uri exists) {
show $uri;
} else {
show 404 page;
}
}
Run Code Online (Sandbox Code Playgroud) 我希望 Apache 索引页面显示我的公司横幅,并在顶部显示主页链接。
代替:
Index of /pub/something
Run Code Online (Sandbox Code Playgroud)
显示
[Company Banner]
Index of /pub/something
Run Code Online (Sandbox Code Playgroud)
我将这些行添加到.htaccess:
HeaderName HEADER.html
ReadmeName README.html
Run Code Online (Sandbox Code Playgroud)
和编辑HEADER.html以包括链接的旗帜,但是这面旗帜只显示/pub不/pub/dir页面页面上。
这是我目前在 .htaccess 中的内容:
Options +Indexes
HeaderName HEADER.html
ReadmeName README.html
Run Code Online (Sandbox Code Playgroud) 如果您访问没有 index.html 的文件夹,Apache 允许您创建目录列表(配置后)。
我想知道的是,是否可以在不同的 URL 处获得相同的列表?我已经在使用 index.html 并希望保持这种状态。
即,这就是我要找的:
http://example.com/blar/-> 加载我的 index.html 页面(不想改变)
http://example.com/blar/directory_list(我希望这个 url 来呈现 apache 目录列表)
apache-2.2 ×4
nginx ×2
rewrite ×2
ext3 ×1
filesystems ×1
fsck ×1
linux ×1
mirror ×1
security ×1
virtualhost ×1