title: Using Socket.io inside an Apache served page
body: <p>I know this has been a recurrent question lately, but despite reading all I could, I couldn't get past this simple problem :</p>
  
  <p>My oversimplified socket server :</p>
  
  <pre><code>var socket = require('socket.io').listen(7000);
  
  socket.on('connection', function(client){
    client.on('message', function(msg){
        socket.broadcast(msg);
    })
  });
  </code></pre>
  
  <p><code>node socket.js</code> output : <code>socket.io started</code></p>
  
  <p><code>http://localhost:7000</code> output : 'Welcome to socket.io'</p>
  
  <p>Index.html (simplified too):</p>
  
  <pre><code>&lt;html&gt;
     &lt;head&gt;
        &lt;script src="http://localhost:7000/socket.io/socket.io.js"&gt;&lt;/script&gt;
        &lt;script src="http://code.jquery.com/jquery-1.6.2.min.js"&gt;&lt;/script&gt;
        &lt;script&gt;
           var name = '';
           var socket = io.connect('http://localhost:7000');
  
           $(document).ready(function(){
              $("button").click(function(){
                 $("p#log").html('sent message: ' + $("input#msg").val());
                 socket.emit('message', $("input#msg").val() );
                 $("p#data_received").append("&lt;br /&gt;\r\n"+ $("input#msg").val());
                 $("input#msg").val('');
              });
           });
  
          socket.on('chat', function (data) {
              console.log(data);
           });
        &lt;/script&gt;
     &lt;/head&gt;
     &lt;body&gt;
        &lt;input type="text" id="msg"&gt;&lt;/input&gt;&lt;button&gt;send&lt;/button&gt;
        &lt;p id="log"&gt;&lt;/p&gt;
        &lt;p id="data_received"&gt;&lt;/p&gt;
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Page displays properly on the apache server. However I get the following, no matter what I tried :</p>
  
  <pre><code>GET http://localhost:7000/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED  
  </code></pre>
  
  <p>I have tried using the full url (node_modules/socket.io/.../dist/socket.io.js), not working.
  Any thoughts? Am I not thinking of something like apache configuration? I'm thinking of moving my entire page to a node server, but the problem still bugs me... </p>