Nordlys logo Straight

Back to all posts

How to set up NGINX as a file server

Published on by Rafik Saifi · 1 min read

NGINX as a file server

Creating a Container

docker run -P -d --name {container name} nginx:latest

Accessing the container

docker exec -it {container name} bash

Editing nginx conf

server {
    listen 80;
    server_name your_domain_or_IP;

    location / {
        root /var/www/files;
        autoindex on;
        autoindex_exact_size off;  # Optional: Show file sizes
        autoindex_localtime on;    # Optional: Show local time
    }
}

This is basic config, should be configured to your needs

Restart the container

docker restart {container name}

Getting container port

docker port {container name}