Nginx: Serving Files

Static assets

The traditional web server.

server {
  listen 80;
  server_name yourdomain.com;
  
  location / {
  	root /path/to/website;
  }
}

Static assets with HTML5 History Mode

Useful for Single-Page Applications like Vue, React, Angular, etc.

server {
  listen 80;
  server_name yourdomain.com;
  root /path/to/website;
  
  location / {
  	try_files $uri $uri/ /index.html;
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *