upstream varnish {
  server localhost:7999;
}

server {
  server_name www.gov.uk www.<%= @app_domain %> www-origin.<%= @app_domain %>;
  listen 80;
  rewrite ^/(.*) https://$host/$1 permanent;
}

# CDN preserves the Host header from original client request and always hits
# this vhost instead of www-origin below.
server {
  server_name         www.gov.uk;
  listen              443 ssl;
  ssl_certificate     /etc/nginx/ssl/www.gov.uk.crt;
  ssl_certificate_key /etc/nginx/ssl/www.gov.uk.key;
  include             /etc/nginx/ssl.conf;

  include             /etc/nginx/router_include.conf;
}

server {
  # www-origin-staging.<appdomain> is necessary as a target for Gor from Production
  server_name         www.<%= @app_domain %> www-origin.<%= @app_domain %> www-origin-staging.<%= @app_domain %>;
  listen              443 ssl;
  ssl_certificate     /etc/nginx/ssl/www.<%= @app_domain %>.crt;
  ssl_certificate_key /etc/nginx/ssl/www.<%= @app_domain %>.key;
  include             /etc/nginx/ssl.conf;

  include             /etc/nginx/router_include.conf;
}

upstream varnish {
  server localhost:7999;
}

server {
  server_name www.gov.uk www.<%= @app_domain %> www-origin.<%= @app_domain %>;
  listen 80;
  rewrite ^/(.*) https://$host/$1 permanent;
}

# CDN preserves the Host header from original client request and always hits
# this vhost instead of www-origin below.
server {
  server_name         www.gov.uk;
  listen              443 ssl;
  ssl_certificate     /etc/nginx/ssl/www.gov.uk.crt;
  ssl_certificate_key /etc/nginx/ssl/www.gov.uk.key;
  include             /etc/nginx/ssl.conf;

  include             /etc/nginx/router_include.conf;
}

server {
  # www-origin-staging.<appdomain> is necessary as a target for Gor from Production
  server_name         www.<%= @app_domain %> www-origin.<%= @app_domain %> draft-origin.<%= @app_domain %> www-origin-staging.<%= @app_domain %>;
  listen              443 ssl;
  ssl_certificate     /etc/nginx/ssl/www.<%= @app_domain %>.crt;
  ssl_certificate_key /etc/nginx/ssl/www.<%= @app_domain %>.key;
  include             /etc/nginx/ssl.conf;

  include             /etc/nginx/router_include.conf;
}

Add draft-origin.<app_domain> to router vhost
Add draft-origin.<app_domain> to router vhost

Add `draft-origin.<app_domain>` to the Nginx virtual host used on the
cache machines.

This is to allow the draft_cache machines to respond to requests
destined for applications supporting draft functionality.
