title: Nginx proxy_pass to Minecraft server
body: <p>I'm trying to run two Minecraft servers on the same machine on two different ports. I want to reference them based on subdomains:</p>
  
  <pre><code>one.example.com -&gt; &lt;minecraft&gt;:25500
  two.example.com -&gt; &lt;minecraft&gt;:25501
  </code></pre>
  
  <p>I have used nginx for things like this before, but it's not working with Minecraft. It's responding with http status 400. Here is a sample from my log:</p>
  
  <pre><code>192.168.0.1 - - [21/Apr/2013:17:25:40 -0700] "\x02&lt;\x00\x0E\x00t\x00h\x00e\x00s\x00a\x00n\x00d\x00y\x00m\x00a\x00n\x001\x002\x003\x00\x1C\x00t\x00e\x00s\x00t\x00.\x00r\x00y\x00a\x00n\x00s\x00a\x00n\x00d\x00y\x00.\x00i\x00s\x00-\x00a\x00-\x00g\x00e\x00e\x00k\x00.\x00c\x00o\x00m\x00\x00c\xDD" 400 173 "-" "-"
  </code></pre>
  
  <p>Here is my nginx config:</p>
  
  <pre><code>upstream mine1 {
    server 127.0.0.1:25500;
  }
  upstream mine2 {
    server 127.0.0.1:25501;
  }
  
  server {
    listen 25565;
    server_name one.example.com;
  
    access_log /var/log/nginx/one.access;
    error_log /var/log/nginx/one.error;
  
    location / {
      proxy_pass http://mine1;
    }
  }
  server {
    listen 25565;
    server_name two.example.com;
  
    access_log /var/log/nginx/two.access;
    error_log /var/log/nginx/two.error;
  
    location / {
      proxy_pass http://mine2;
    }
  }
  </code></pre>
  
  <p>If I'm reading this correctly, nginx is responding with 400. My guess is the Minecraft client is not sending valid HTTP headers and Nginx is tossing out the request. But I'm totally at a loss. Any help would be appreciated.</p>