<%
=begin

Cookbook Name:: nginx
Attributes:: default

Author:: Damian Curry (<damian.curry@nginx.com>)

Copyright (c) 2017-present, NGINX, Inc.

This source code is licensed under the Apache License (v2.0) found in the LICENSE file in
the root directory of this source tree.

=end
%>

server {
  listen 80;
  server_name <%= node['nginx']['server_name'] %>;
  status_zone <%= node['nginx']['server_name'] %>;

  access_log            /var/log/nginx/<%= node['nginx']['server_name'] %>.log combined;
  error_log             /var/log/nginx/<%= node['nginx']['server_name'] %>.error.log;

  location / {
    proxy_pass            http://<%= node['nginx']['upstream'] %>;
    health_check;
    limit_rate 1000;
    proxy_set_header      Host $host;
    proxy_set_header      X-Real-IP $remote_addr;
    proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
