server {
	listen      443 ssl;
	server_name hosthosthost;

	proxy_intercept_errors on;

	ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers               RC4:HIGH:!aNULL:!MD5:!kEDH;
	ssl_prefer_server_ciphers on;
	ssl_certificate           /etc/pki-custom/fullchain.crt;
	ssl_certificate_key       /etc/pki-custom/privkey.key;
	ssl_session_cache         shared:SSL:10m;
	ssl_session_timeout       10m;

	location @start {
		rewrite ^(/a/[a-zA-Z0-9_]+/([0-9]+/)?).*$ $1 last;
	}

	location /availability/ {
		include               1c_common.conf;
		recursive_error_pages on;
		error_page            400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505  /i/index.html;
		proxy_pass            http://upstream_availability;
	}

	location /i {
		alias /var/www/failover;
	}


	location ^~ /a/openid {
		include    1c_common.conf;
		include    1c_keepalive.conf;
		include    1c_error_openid.conf;
		proxy_pass http://backend83;
	}

	location ^~ /a/adm/e1cib/start {
		include    1c_app.conf;
		include    1c_error.conf;
		include    1c_keepalive.conf;
		error_page 400 403 412 @start;
		proxy_pass http://backend83;
	}

	location ^~ /a/adm {
		include    1c_app.conf;
		include    1c_error.conf;
		include    1c_keepalive.conf;
		proxy_pass http://backend83;
	}
	
	location ^~ /a/extreg {
		include    1c_app.conf;
		include    1c_error.conf;
		include    1c_keepalive.conf;
		proxy_pass http://backend83;
	}

	location ^~ /a/wcib/hs {
		include    1c_app.conf;
		include    1c_error.conf;
		keepalive_timeout 0;
		proxy_pass http://backend83;
	}

	location ^~ /a/httpextreg/hs {
		include    1c_app.conf;
		include    1c_error.conf;
		keepalive_timeout 0;
		proxy_pass http://backend83;
	}

	location ^~ /a/wcibprivate/hs {
		include    1c_app.conf;
		include    1c_error.conf;
		keepalive_timeout 0;
		proxy_pass http://backend83;
	}

	location ~* /a/\w+/\d+/e1cib/start {
		include    1c_app.conf;
		include    1c_error.conf;
		error_page 400 403 412 @start;
		proxy_pass http://gate;
	}

	location ~* /a/\w+/\d+/\w+/e1cib/oid2rp {
		include    1c_app.conf;
		include    1c_error.conf;
		error_page 400 403 404 412 @start;
		proxy_pass http://gate;
	}

	location ~* /a/\w+/\d+/ws {
		include                1c_app.conf;
		proxy_intercept_errors off;
		proxy_pass             http://gate;
	}

	location ~* /a/\w+/\d+ {
		include    1c_app.conf;
		include    1c_error.conf;
		proxy_pass http://gate;
	}

	location / {
		include    1c_common.conf;
		include    1c_keepalive.conf;
		include    1c_error_site.conf;
		proxy_pass http://sitesitesite:8080;
	}

	location /resources/images/content {
		alias /var/www/content/media;
	}

	location /extreg {
		alias /var/www/extreg;
	}

}
