Created
November 3, 2017 23:42
-
-
Save muratcorlu/bae35db86429684f018d4c9f0b6123ca to your computer and use it in GitHub Desktop.
Serve static websites by dynamically mapping domain names and folders with nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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