Skip to content

Instantly share code, notes, and snippets.

@manjeshpv
Created May 8, 2019 08:57
Show Gist options
  • Save manjeshpv/7d2bf2808d244fd64b6176812b99807c to your computer and use it in GitHub Desktop.
Save manjeshpv/7d2bf2808d244fd64b6176812b99807c to your computer and use it in GitHub Desktop.
nginx config for angular-fullstack
# cache directive for all static apps
index index.html;
# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|eot|otf|woff|woff2|ttf|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location / {
#if ($args !~* _v=110917) {
# return 301 https://$server_name$uri?_v=110917&$args;
#}
try_files $uri $uri/ /index.html;
expires -1;
}
@manjeshpv
Copy link
Author

sudo nano /etc/nginx/frontend

@manjeshpv
Copy link
Author

manjeshpv commented May 8, 2019

add include frontend; in your conf file

server {
  listen 80;

  server_name example.com;
  root /home/user/username/repo/dist/client;

  include frontend;
}

@manjeshpv
Copy link
Author

sudo nano /etc/nginx/gzip

##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment