<commit_before>#!/bin/bash

cat <<EOF
upstream unicorn {
  server unix:/tmp/unicorn.dashboard.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  # server_name example.com;

  root ${DASH_ROOT}/public;
  try_files \$uri/index.html \$uri @unicorn;

  location ~ /blockly/* {
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET';
    add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  }

  location @unicorn {
EOF

if [[ $RAILS_ENV = 'production' ]]; then
cat <<EOF
    if ($host != "learn.code.org") {
      rewrite /?(.*) http://learn.code.org/$1 permanent;
    }
EOF
fi

cat <<EOF
    proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
    proxy_set_header Host \$http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}
EOF<commit_msg>Escape $host, since we don't want it subbed by bash<commit_after>#!/bin/bash

cat <<EOF
upstream unicorn {
  server unix:/tmp/unicorn.dashboard.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  # server_name example.com;

  root ${DASH_ROOT}/public;
  try_files \$uri/index.html \$uri @unicorn;

  location ~ /blockly/* {
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET';
    add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  }

  location @unicorn {
EOF

if [[ $RAILS_ENV = 'production' ]]; then
cat <<EOF
    if (\$host != "learn.code.org") {
      rewrite /?(.*) http://learn.code.org/$1 permanent;
    }
EOF
fi

cat <<EOF
    proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
    proxy_set_header Host \$http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}
EOF
{'fraction_non_alphanumeric': 0.14096109839816934, 'fraction_numerical': 0.020137299771167048, 'mean_word_length': 3.804395604395604, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2055913', 'n_tokens_mistral': 854, 'n_tokens_neox': 789, 'n_words': 156}