{% if RUN_CMS %}
upstream cms-backend {
    server cms:8000 fail_timeout=0;
}

server {
  listen 80;
  server_name {{ CMS_HOST }};

  access_log /var/log/nginx/access.log tutor;
  client_max_body_size 250M;
  server_tokens off;

  rewrite ^(.*)/favicon.ico$ /static/images/favicon.ico last;

  location @proxy_to_cms_app {
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_pass http://cms-backend;
  }

  location / {
    try_files $uri @proxy_to_cms_app;
  }

  {{ patch("nginx-cms")|indent(2) }}
}
{% endif %}
