server {
  listen {{ jenkins_nginx_port }};
  server_name {{ jenkins_server_name }};

  location / {
    proxy_pass              http://localhost:{{ jenkins_port }};

    {% if jenkins_protocol_https %}
    # Rewrite HTTPS requests from WAN to HTTP requests on LAN
    proxy_redirect http:// https://;
    {% endif %}

    # The following settings from https://wiki.jenkins-ci.org/display/JENKINS/Running+Hudson+behind+Nginx
    sendfile off;

    proxy_set_header        Host $http_host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_connect_timeout   150;
    proxy_send_timeout      100;
    proxy_read_timeout      100;
    proxy_buffers           4 32k;
    client_max_body_size    16m;
    client_body_buffer_size 128k;

  }
}
