title: Adding expire headers in nginx
body: <p>It used to be so easy to set header expiration with apache mod_headers, but I am having a hard time to figure out where to add it in nginx confi file.
  This is my nginx.conf:</p>
  
  <pre><code>#user  nginx;
  worker_processes  1;
  
  #error_log  /var/log/nginx/error.log;
  #error_log  /var/log/nginx/error.log  notice;
  #error_log  /var/log/nginx/error.log  info;
  
  #pid        /var/run/nginx.pid;
  
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
      #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
      #                  '$status $body_bytes_sent "$http_referer" '
      #                  '"$http_user_agent" "$http_x_forwarded_for"';
  
      #access_log  /var/log/nginx/access.log  main;
  
      sendfile        on;
      #tcp_nopush     on;
  
      #keepalive_timeout  0;
      keepalive_timeout  65;
      #tcp_nodelay        on;
      tcp_nodelay        on;
  
      gzip  on;
      gzip_http_version 1.1;
      #gzip_http_version 1.0;
      gzip_vary on;
      gzip_comp_level 6;
      gzip_proxied any;
      gzip_types text/plain text/html text/css application/x-javascript text/xml;
      #gzip_min_length  1100;
      gzip_buffers 16 8k;
      gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  
      server_tokens off;
  
      include /etc/nginx/conf.d/*.conf;
  
  }
  </code></pre>
  
  <p>Where should I add the header expiration part like</p>
  
  <pre><code>location ~* \.(js|css)$ {
    expires 30d;
  }
  </code></pre>
  
  <p>I tried adding it inside "http" or including in another block "server", but it generates errors like unknown directive "server" or "location".</p>