Simple Nginx Application Configuration

Posted by Weston Ganger on July 12, 2016

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:

  listen 80;
  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:

Posted in Linux and Tagged with nginx 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts