Nginx

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:


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:


Posted in Linux and Tagged with nginx 


Need help on your next project or application?

I specialize in Ruby-on-Rails, AngularJS, Javascript, Bootstrap, and Hybrid Mobile Apps with Cordova & Ionic.

Contact Me

Recommended Posts