Simple Nginx Application Configuration

Posted By Weston Ganger

I usually have more complicated applications but I had some simple HTML/JS/CSS applications that I wanted to serve from my Nginx server. Heres a simple config for these cases:

server{
  listen 80;
  server_name mysite.com;
  root /usr/share/nginx/html/my_site/;
  index index.html;

  # Compress assets, Assuming the js and css are in /usr/share/nginx/html/my_site/js and /usr/share/nginx/html/my_site/css
  location ~ ^/(js|css)/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    add_header Last-Modified "";
    add_header ETag "";
  }
}

Related External Links:

Article Topic:Software Development - Linux

Date:July 12, 2016