in lib/ES/Util.pm [590:653]
sub write_nginx_preview_config {
#===================================
my ( $dest ) = @_;
my $preview_conf = <<"CONF";
proxy_pass http://0.0.0.0:3000;
proxy_http_version 1.1;
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
proxy_buffering off;
gzip on;
add_header 'Access-Control-Allow-Origin' '*';
if (\$request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'kbn-xsrf-token';
}
CONF
# We log the X-Opaque-Id which is a header that Elasticsearch uses to mark
# requests with an id that is opaque to Elasticsearch. Presumably this is
# a standard. Either way we follow along. We use it in our tests so we can
# figure out which request came from which test. That is the only reason
# we *need* it right now. Presumably we'll find some other use for it later
# though. Think of it as a distributed trace id.
my $nginx_conf = <<"CONF";
daemon off;
error_log /dev/stdout info;
pid /run/nginx/nginx.pid;
events {
worker_connections 64;
}
http {
error_log /dev/stdout crit;
log_format short '\$http_x_opaque_id \$http_host \$request \$status';
access_log /dev/stdout short;
server {
listen 8000;
location = /liveness {
return 200 "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.";
}
location = /robots.txt {
return 200 "User-agent: *\nDisallow: /\n";
}
location ~/(guide|diff) {
$preview_conf
}
location / {
alias /docs_build/resources/web/static/;
try_files \$uri \@preview;
autoindex off;
}
location \@preview {
$preview_conf
}
rewrite ^/assets/(.+)\$ https://www.elastic.co/assets/\$1 permanent;
rewrite ^/gdpr-data\$ https://www.elastic.co/gdpr-data permanent;
rewrite ^/static/(.+)\$ https://www.elastic.co/static/\$1 permanent;
}
}
CONF
$dest->spew( iomode => '>:utf8', $nginx_conf );
}