Skip to content

Instantly share code, notes, and snippets.

@sergeioff
Created August 16, 2017 15:01
Show Gist options
  • Save sergeioff/de7eeff3cc9295b48bdfe7cd6d1f6743 to your computer and use it in GitHub Desktop.
Save sergeioff/de7eeff3cc9295b48bdfe7cd6d1f6743 to your computer and use it in GitHub Desktop.
Nginx configuration for angular
root /var/www/html/;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location ~ ([^\/]+)(?=\/.\.js$|\.js$){
try_files $uri $uri/ /ui/$1.js;
}
location ~ ([^\/]+)(?=\/.\.svg$|\.svg$){
try_files $uri $uri/ /ui/$1.svg;
}
location ~ ([^\/]+)(?=\/.\.eot$|\.eot$){
try_files $uri $uri/ /ui/$1.eot;
}
location ~ ([^\/]+)(?=\/.\.ico$|\.ico$){
try_files $uri $uri/ /ui/$1.ico;
}
location ~ ([^\/]+)(?=\/.\.woff2$|\.woff2$){
try_files $uri $uri/ /ui/$1.woff2;
}
location ~ ([^\/]+)(?=\/.\.ttf$|\.ttf$){
try_files $uri $uri/ /ui/$1.ttf;
}
location ~ ([^\/]+)(?=\/.\.woff$|\.woff$){
try_files $uri $uri/ /ui/$1.woff;
}
location ~ ([^\/]+)(?=\/.\.map$|\.map$){
try_files $uri $uri/ /ui/$1.map;
}
location ~ assets(.*) {
try_files $uri $uri/ /ui/assets/$1;
}
location ~ ^/ui {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalicate, post-check=0 pre-check=0";
try_files $uri $uri/ /ui/index.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment