Serve Files & Directories

Share files and directories instantly over HTTPS with a public URL

Basic Usage

The ngsrv serve command creates a simple file server with directory browsing.

ngsrv serve [directory]

If no directory is specified, serves the current directory

Examples

Serve current directory

ngsrv serve

Serves all files in the current directory with directory listing

Serve specific directory

ngsrv serve ./public

Serves only files in the ./public directory

With custom domain

ngsrv serve ./docs --domain mydocs

Serves docs folder at mydocs.tnl.ngsrv.com

With password protection

ngsrv serve ./files --policy ngsrv_auth_ABC123

Requires header authentication to access files

Pin the local port (e.g. for predictable dashboards)

ngsrv serve ./public --port 8080

Runs the in-process file server on localhost:8080 instead of a random port.

Replace an existing tunnel on the same domain

ngsrv serve ./public --domain mydocs --force

Terminates any existing tunnel bound to mydocs before starting this one.

Flags

FlagDescriptionDefault
--domain, -dDomain to use (subdomain name or full FQDN).team default / random
--port, -pLocal port for the in-process file server.random
--force, -fTerminate any existing tunnel on the same domain before starting.false
--policySecurity policy ID to apply. Repeat the flag to apply several.none

Features

Directory Browsing

Automatic directory listing with file sizes and last modified dates

MIME Type Detection

Automatically sets correct content types for all file formats

HTTPS by Default

All file transfers are encrypted over HTTPS

Range Requests

Supports partial content delivery for large files and video streaming

Common Use Cases

Quick File Sharing

Share project files with remote team members without email attachments

Static Site Preview

Preview static HTML/CSS/JS sites before deploying to production

Documentation Sharing

Share generated documentation (like JSDoc or Sphinx output) with stakeholders

Build Artifact Distribution

Temporarily share compiled binaries or build artifacts for testing

Security Considerations

⚠️ Important

  • • All files in the directory become publicly accessible
  • • Use security policies to restrict access
  • • Don't serve directories containing sensitive data
  • • Consider using --policy for authentication

Recommended Security Policies