real_ip_header X-Forwarded-For;

# Prevent mobile network providers from modifying your site
add_header "Cache-Control" "no-transform";

server {
  # don't forget to tell on which port this server listens
  listen 80;

  # listen on the www host
  server_name www.maxdegterev.name;

  # and redirect to the non-www host (declared below)
  return 301 $scheme://maxdegterev.name$request_uri;
}

server {
  listen 80;
  #listen 443 ssl;

  server_name maxdegterev.name;
  charset utf-8;
  access_log /var/log/nginx/maxdegterev.access.log;

  error_page 404 /404.html;
  error_page 502 /deploy.html;

  # Compressing and setting expires
  location ~ /(assets|fonts|.*\.(txt|html)) {
    root /var/www/maxdegterev/public;
    gzip_static on;
    gzip_vary on;
    #gzip_types application/x-javascript image/svg+xml;
    expires max;
    access_log off;
  }

  # Just expires
  location ~ /(favicon.ico|.*\.png) {
    root /var/www/maxdegterev/public;
    expires max;
    access_log off;
  }

  # Only pass through, minor expiration time
  location ~ /images {
    root /var/www/maxdegterev/public;
    expires 24h;
    access_log off;
  }

  location / {
    gzip on;
    gzip_static on;
    gzip_comp_level 5;
    gzip_min_length 200;
    gzip_proxied any;
    gzip_types text/plain application/xml application/json;

    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    #proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
  }
}
