# Configuring NGINX to Serve a Directory Listing

DevFeed: [Configuring NGINX to Serve a Directory Listing](<https://devfeed.tech/articles/configuring-nginx-to-serve-a-directory-listing-28203.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/nginx/2020/06/15/configuring-nginx-to-serve-a-directory-listing.html>)

Author: Fuzzygroup

Published: 2020-06-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [nginx](<https://devfeed.tech/topics/nginx.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Ubuntu](<https://devfeed.tech/topics/ubuntu.md>), [AWS Lambda](<https://devfeed.tech/topics/aws-lambda.md>), [Server](<https://devfeed.tech/topics/server.md>)

Tags: [aws-lambda](<https://devfeed.tech/tags/aws-lambda.md>), [commands](<https://devfeed.tech/tags/commands.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [linux](<https://devfeed.tech/tags/linux.md>), [nginx](<https://devfeed.tech/tags/nginx.md>), [server](<https://devfeed.tech/tags/server.md>), [ubuntu](<https://devfeed.tech/tags/ubuntu.md>)

## AI overview

This tutorial explains how to configure NGINX to serve a directory listing using the autoindex on directive. It covers the relevant NGINX configuration files, useful service commands, and an example location and server configuration on Ubuntu Linux.

## Source excerpt

I recently had to setup an NGINX server to serve a directory of files for processing via an AWS Lambda function. And while there are other ways to do this, NGINX offered an easy, convenient way to do this albeit at the cost of some configuration. The trick to this is the autoindex on directive but it needs to exist in the right place in your overall NGINX configuration. My operating system was: Ubuntu Linux 18 Nginx version: nginx/1.14.0 (Ubuntu) Useful NGINX Commands Here are some useful commands for working with NGINX: nginx -v (find the version) sudo systemctl status nginx (get status) sudo systemctl restart nginx (restart the server) sudo systemctl stop nginx (stop the server) sudo systemctl start nginx (start the server) The Overall NGINX Configuration Structure I've always hacked about with NGINX and never really understand how NGINX was configured. Much to my surprise, NGINX is very similar to the old school Apache structure that I used to dearly love: There is a default configuration in: /etc/nginx/nginx.conf The site level configuration is in /etc/nginx/sites-available/default It is in this file /etc/nginx/sites-available/default that you can add a location directive: location /home/ubuntu/data/data { autoindex on; } and this goes inside the overall server block like this: server { listen 80 default_server; listen [::]:80 default_server; location /home/ubuntu/data/data { autoindex on; } My actual configuration looks like this: root /home/ubuntu/data/data; # Add index.php to the list if you are using PHP #index index.html index.htm index.nginx-debian.html; autoindex on; server_name _; location /home/ubuntu/data/data { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; }