# Serve PR-preview requests server { server_name "~^pr(?[1-9][0-9]*)-(?[0-9a-f]{40})\."; listen {{$AIO_NGINX_PORT_HTTP}}; listen [::]:{{$AIO_NGINX_PORT_HTTP}}; listen {{$AIO_NGINX_PORT_HTTPS}} ssl; listen [::]:{{$AIO_NGINX_PORT_HTTPS}} ssl; ssl_certificate /etc/ssl/localcerts/{{$AIO_DOMAIN_NAME}}.crt; ssl_certificate_key /etc/ssl/localcerts/{{$AIO_DOMAIN_NAME}}.key; root {{$AIO_BUILDS_DIR}}/$pr/$sha; disable_symlinks on from=$document_root; index index.html; location / { try_files $uri $uri/ =404; } } # Handle all other requests server { server_name _; listen {{$AIO_NGINX_PORT_HTTP}} default_server; listen [::]:{{$AIO_NGINX_PORT_HTTP}}; listen {{$AIO_NGINX_PORT_HTTPS}} ssl default_server; listen [::]:{{$AIO_NGINX_PORT_HTTPS}} ssl; ssl_certificate /etc/ssl/localcerts/{{$AIO_DOMAIN_NAME}}.crt; ssl_certificate_key /etc/ssl/localcerts/{{$AIO_DOMAIN_NAME}}.key; # Health check location "~^\/health-check\/?$" { add_header Content-Type text/plain; return 200 ''; } # Upload builds location "~^\/create-build\/(?[1-9][0-9]*)\/(?[0-9a-f]{40})\/?$" { if ($request_method != "POST") { add_header Allow "POST"; return 405; } client_body_temp_path /tmp/aio-create-builds; client_body_buffer_size 128K; client_max_body_size {{$AIO_UPLOAD_MAX_SIZE}}; client_body_in_file_only on; proxy_pass_request_headers on; proxy_set_header X-FILE $request_body_file; proxy_set_body off; proxy_redirect off; proxy_method GET; proxy_pass http://{{$AIO_UPLOAD_HOSTNAME}}:{{$AIO_UPLOAD_PORT}}$request_uri; resolver 127.0.0.1; } # Everything else location / { return 404; } }