Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Serve static websites by dynamically mapping domain names and folders with nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/${host}/public;
index index.html;
server_name _;
gzip on;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# 404 if a file is requested (so the main app isn't served)
location ~ ^.+\..+$ {
try_files $uri =404;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.