server {
  listen 51000;
  server_name <%= all_domains.join(" ") %>;

  # Write the real client IP when it's passed via X-Forwarded-For from HAProxy.
  set_real_ip_from 127.0.0.1;
  real_ip_header X-Forwarded-For;

  access_log <%= current_path %>/log/access.log combined;
  error_log <%= current_path %>/log/error.log;

  root <%= current_path %>/public;

  # Allow for larger request bodies to allow for huge documentation pages.
  client_max_body_size 10m;

  <% torquebox_apps.each do |app| %>
    # Serve non-static resources with Torquebox.
    try_files $uri/index.html $uri.html $uri @app;
    location @app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_redirect off;
      proxy_pass http://<%= app[:host] %>:<%= torquebox_http_port %>;
    }
  <% end %>
}

server {
  listen 51000;
  server_name <%= all_domains.join(" ") %>;

  # Write the real client IP when it's passed via X-Forwarded-For from HAProxy.
  set_real_ip_from 127.0.0.1;
  real_ip_header X-Forwarded-For;

  access_log <%= current_path %>/log/access.log combined;
  error_log <%= current_path %>/log/error.log;

  root <%= current_path %>/public;

  # Allow for larger request bodies to allow for huge documentation pages.
  client_max_body_size 10m;

  <% torquebox_apps.each do |app| %>
    # Serve non-static resources with Torquebox.
    try_files $uri/index.html $uri.html $uri @app;
    location @app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_redirect off;

      proxy_set_header  Host <%= app[:host] %>;
      proxy_pass http://127.0.0.1:<%= torquebox_http_port %>;
    }
  <% end %>
}

Fix proxying to torquebox when dynamic, internal domains don't resolve.
Fix proxying to torquebox when dynamic, internal domains don't resolve.
