| 
									
										
										
										
											2017-03-08 16:29:37 +02:00
										 |  |  | # Redirect all HTTP traffic to HTTPS | 
					
						
							|  |  |  | server { | 
					
						
							|  |  |  |   server_name _; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   listen {{$AIO_NGINX_PORT_HTTP}} default_server; | 
					
						
							|  |  |  |   listen [::]:{{$AIO_NGINX_PORT_HTTP}}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 16:30:55 +02:00
										 |  |  |   access_log {{$AIO_NGINX_LOGS_DIR}}/access.log; | 
					
						
							|  |  |  |   error_log  {{$AIO_NGINX_LOGS_DIR}}/error.log; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 16:29:37 +02:00
										 |  |  |   # Ideally we want 308 (permanent + keep original method), | 
					
						
							|  |  |  |   # but it is relatively new and not supported by some clients (e.g. cURL). | 
					
						
							|  |  |  |   return 307 https://$host:{{$AIO_NGINX_PORT_HTTPS}}$request_uri; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | # Serve PR-preview requests | 
					
						
							|  |  |  | server { | 
					
						
							| 
									
										
										
										
											2017-06-25 22:13:03 +03:00
										 |  |  |   server_name "~^pr(?<pr>[1-9][0-9]*)-(?<sha>[0-9a-f]{7,40})\."; | 
					
						
							| 
									
										
										
										
											2017-02-27 12:11:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 07:07:28 +03:00
										 |  |  |   listen {{$AIO_NGINX_PORT_HTTPS}} ssl http2; | 
					
						
							|  |  |  |   listen [::]:{{$AIO_NGINX_PORT_HTTPS}} ssl http2; | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 07:07:28 +03:00
										 |  |  |   ssl_certificate           {{$AIO_LOCALCERTS_DIR}}/{{$AIO_DOMAIN_NAME}}.crt; | 
					
						
							|  |  |  |   ssl_certificate_key       {{$AIO_LOCALCERTS_DIR}}/{{$AIO_DOMAIN_NAME}}.key; | 
					
						
							|  |  |  |   ssl_prefer_server_ciphers on; | 
					
						
							|  |  |  |   ssl_ciphers               EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   root             {{$AIO_BUILDS_DIR}}/$pr/$sha; | 
					
						
							|  |  |  |   disable_symlinks on from=$document_root; | 
					
						
							|  |  |  |   index            index.html; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-11 00:22:16 +03:00
										 |  |  |   gzip            on; | 
					
						
							|  |  |  |   gzip_comp_level 7; | 
					
						
							|  |  |  |   gzip_types      *; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 16:30:55 +02:00
										 |  |  |   access_log {{$AIO_NGINX_LOGS_DIR}}/access.log; | 
					
						
							|  |  |  |   error_log  {{$AIO_NGINX_LOGS_DIR}}/error.log; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-01 23:19:58 +03:00
										 |  |  |   error_page 404 /404.html; | 
					
						
							|  |  |  |   location "=/404.html" { | 
					
						
							|  |  |  |     internal; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-13 18:35:16 +02:00
										 |  |  |   location "~/[^/]+\.[^/]+$" { | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  |     try_files $uri $uri/ =404; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-03-13 18:35:16 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   location / { | 
					
						
							| 
									
										
										
										
											2017-03-21 15:46:20 +02:00
										 |  |  |     try_files $uri $uri/ /index.html =404; | 
					
						
							| 
									
										
										
										
											2017-03-13 18:35:16 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Handle all other requests | 
					
						
							|  |  |  | server { | 
					
						
							| 
									
										
										
										
											2017-02-27 12:11:55 +02:00
										 |  |  |   server_name _; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 07:07:28 +03:00
										 |  |  |   listen {{$AIO_NGINX_PORT_HTTPS}} ssl http2 default_server; | 
					
						
							|  |  |  |   listen [::]:{{$AIO_NGINX_PORT_HTTPS}} ssl http2; | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 07:07:28 +03:00
										 |  |  |   ssl_certificate           {{$AIO_LOCALCERTS_DIR}}/{{$AIO_DOMAIN_NAME}}.crt; | 
					
						
							|  |  |  |   ssl_certificate_key       {{$AIO_LOCALCERTS_DIR}}/{{$AIO_DOMAIN_NAME}}.key; | 
					
						
							|  |  |  |   ssl_prefer_server_ciphers on; | 
					
						
							|  |  |  |   ssl_ciphers               EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 16:30:55 +02:00
										 |  |  |   access_log {{$AIO_NGINX_LOGS_DIR}}/access.log; | 
					
						
							|  |  |  |   error_log  {{$AIO_NGINX_LOGS_DIR}}/error.log; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  |   # Health check | 
					
						
							| 
									
										
										
										
											2017-03-13 18:35:16 +02:00
										 |  |  |   location "~^/health-check/?$" { | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  |     add_header Content-Type text/plain; | 
					
						
							|  |  |  |     return 200 ''; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-26 00:29:14 +03:00
										 |  |  |   # Check PRs previewability | 
					
						
							|  |  |  |   location "~^/can-have-public-preview/\d+/?$" { | 
					
						
							|  |  |  |     if ($request_method != "GET") { | 
					
						
							|  |  |  |       add_header Allow "GET"; | 
					
						
							|  |  |  |       return 405; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     proxy_pass_request_headers on; | 
					
						
							|  |  |  |     proxy_redirect             off; | 
					
						
							|  |  |  |     proxy_method               GET; | 
					
						
							|  |  |  |     proxy_pass                 http://{{$AIO_PREVIEW_SERVER_HOSTNAME}}:{{$AIO_PREVIEW_SERVER_PORT}}$request_uri; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     resolver 127.0.0.1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 18:54:13 +01:00
										 |  |  |   # Notify about CircleCI builds | 
					
						
							|  |  |  |   location "~^/circle-build/?$" { | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  |     if ($request_method != "POST") { | 
					
						
							|  |  |  |       add_header Allow "POST"; | 
					
						
							|  |  |  |       return 405; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     proxy_pass_request_headers on; | 
					
						
							|  |  |  |     proxy_redirect             off; | 
					
						
							| 
									
										
										
										
											2018-05-09 18:54:13 +01:00
										 |  |  |     proxy_method               POST; | 
					
						
							| 
									
										
										
										
											2018-08-15 13:47:45 +01:00
										 |  |  |     proxy_pass                 http://{{$AIO_PREVIEW_SERVER_HOSTNAME}}:{{$AIO_PREVIEW_SERVER_PORT}}$request_uri; | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     resolver 127.0.0.1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-27 19:43:02 +03:00
										 |  |  |   # Notify about PR changes | 
					
						
							|  |  |  |   location "~^/pr-updated/?$" { | 
					
						
							|  |  |  |     if ($request_method != "POST") { | 
					
						
							|  |  |  |       add_header Allow "POST"; | 
					
						
							|  |  |  |       return 405; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     proxy_pass_request_headers on; | 
					
						
							|  |  |  |     proxy_redirect             off; | 
					
						
							|  |  |  |     proxy_method               POST; | 
					
						
							| 
									
										
										
										
											2018-08-15 13:47:45 +01:00
										 |  |  |     proxy_pass                 http://{{$AIO_PREVIEW_SERVER_HOSTNAME}}:{{$AIO_PREVIEW_SERVER_PORT}}$request_uri; | 
					
						
							| 
									
										
										
										
											2017-06-27 19:43:02 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     resolver 127.0.0.1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-06 20:40:28 +02:00
										 |  |  |   # Everything else | 
					
						
							|  |  |  |   location / { | 
					
						
							|  |  |  |     return 404; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |