大网数据广告活动
服务器运维问答

nginx directory listing on Ubuntu

· 52CE 我爱测

I searched a lot and everyone says add these in config file and it will work: location /my_directory { autoindex on; } I opened /etc/nginx/nginx.conf file and added it under http but service did not start. Added it under http -> …

问题原文

原帖链接 · Mustafa Chelik · CC BY-SA 3.0

I searched a lot and everyone says add these in config file and it will work:

location /my_directory {
    autoindex on;
}

I opened /etc/nginx/nginx.conf file and added it under http but service did not start. Added it under http -> server and received 403 forbidden error.

I have no idea about nginx. Can someone tell me easily about what should I do?

Thanks

已采纳解答

原帖链接 · Tero Kilkanen · CC BY-SA 3.0

You need to add the:

location /my_directory {
    autoindex on;
}

In the file in your /etc/nginx/sites-enabled directory that corresponds to the virtual host your site is using. There is already a server block in the file, so you simply place the location block inside the server block.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。