<commit_before>upstream rails {
  server web:3000 fail_timeout=0;
}

# gitorious-http-backend is running on the host (because we want custom hooks
# to be run *on the host*), so here we point Nginx to port 6000 of Docker host.
upstream gitorious_http_backend {
  server <%= ENV['HOST_IP'] %>:6000 fail_timeout=0;
}

upstream git_archive_daemon {
  server archiver:5000 fail_timeout=0;
}

server {
  listen 80;
  root /usr/src/app/public;
  try_files $uri/index.html $uri.html $uri @app;

  # Set maximum allowed size of the client request body.
  # It's overriden later (in sections below) for gitorious-http-backend to allow http pushing.
  client_max_body_size 1m;

  # Proxy requests to Rails app
  location @app {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_pass http://rails;
    proxy_redirect off;
    error_page 500 502 504 /500.html; # RAILS error pages
  }

  # Prevent accessing internal API from the internet
  location ~ ^/api/internal {
    return 404;
  }

  # Proxy "git paths" to gitorious-http-backend (HTTP cloning/pushing)
  location ~* ^/[^\/]+/[^.]+\.git {
    # Make sure we don't limit allowed size of the client request body (so pushing big repos works)
    client_max_body_size 0;

    # Don't buffer anything, return it straight to the client (so cloning big repos works)
    proxy_buffering off;
    proxy_read_timeout 120s;

    proxy_pass http://gitorious_http_backend;
  }

  # Proxy internal requests for archives to git-archive-daemon
  location ~* ^/_internal/archiver/ {
    internal;

    # Don't buffer anything, return it straight to the client (so streaming of big archives works)
    proxy_buffering off;
    proxy_read_timeout 120s;

    rewrite /_internal/archiver(/.*) $1 break;
    proxy_pass http://git_archive_daemon;
  }

  # Add caching headers for static assets
  location ~ ^/assets/ {
    expires 1y;
    add_header Cache-Control public;

    add_header ETag "";
    break;
  }
}<commit_msg>No need for upstream definitions<commit_after>server {
  listen 80;
  root /usr/src/app/public;
  try_files $uri/index.html $uri.html $uri @app;

  # Set maximum allowed size of the client request body.
  # It's overriden later (in sections below) for gitorious-http-backend to allow http pushing.
  client_max_body_size 1m;

  # Proxy requests to Rails app
  location @app {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_pass http://web:3000$request_uri;
    proxy_redirect off;
    error_page 500 502 504 /500.html; # RAILS error pages
  }

  # Prevent accessing internal API from the internet
  location ~ ^/api/internal {
    return 404;
  }

  # Proxy "git paths" to gitorious-http-backend (HTTP cloning/pushing)
  location ~* ^/[^\/]+/[^.]+\.git {
    # Make sure we don't limit allowed size of the client request body (so pushing big repos works)
    client_max_body_size 0;

    # Don't buffer anything, return it straight to the client (so cloning big repos works)
    proxy_buffering off;
    proxy_read_timeout 120s;

    # gitorious-http-backend is running on the host (because we want custom hooks
    # to be run *on the host*), so here we point Nginx to port 6000 of Docker host.
    proxy_pass http://<%= ENV['HOST_IP'] %>:6000$request_uri;
  }

  # Proxy internal requests for archives to git-archive-daemon
  location ~* ^/_internal/archiver/ {
    internal;

    # Don't buffer anything, return it straight to the client (so streaming of big archives works)
    proxy_buffering off;
    proxy_read_timeout 120s;

    rewrite /_internal/archiver(/.*) $1 break;
    proxy_pass http://archiver:5000$request_uri;
  }

  # Add caching headers for static assets
  location ~ ^/assets/ {
    expires 1y;
    add_header Cache-Control public;

    add_header ETag "";
    break;
  }
}
{'fraction_non_alphanumeric': 0.09043863972400197, 'fraction_numerical': 0.02193198620009857, 'mean_word_length': 3.455543358946213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4137202', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1270, 'n_words': 426}