Search code examples
apacheportcomet

Port Number for Comet Server alongside apache


I'm desirous of setting up a comet server for php / js. I'm going to use nginx alongside Apache. In doing so, I believe I need to have one port open for Apache and another for my comet server. I have heard they can share a port through such magic as "Reverse Proxy" and "Proxy Pass". These phrases strike fear into my heart. I think the easiest is to have one port for each. Is this wise?

If I do have two ports, obviously I will use 80/443 for Apache, but what about my coment server? Does it matter what ports I choose? Is 8080 just as good or bad as 8888, or 10101?


Solution

  • The port number to use shouldn't necessary matter as long as it's selected with care (No conflicting ports etc). The real issue is dealing with cross domain requests. Because the port is technically on another server, we face issues with cross domain requests. So using a different port number is not a very good solution.

    It turns out the reverse proxy isn't as scary as I thought, I just added the following lines to htaccess:

    ProxyRequests Off
    ProxyPass /comet http://localhost:8888
    ProxyPassReverse /comet  http://localhost:8888
    

    Where 8888 was the port that I used. I then made all my requests to /comet instead of the port 8888.