Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running a Meteor server on my Ubuntu server. But problems arise when I try to have Apache serving a subdomain on the same server.

main.domain.com -> Meteor

sub.domain.com -> Apache

Meteor is running on port 80. I have previously tried to have Meteor run on port 3000 and served in reverse proxy with Nginx, but Meteor started to behave badly (tcp/websockets issues) and I spent too many evenings and nights to persist for my own sake.

So I reverted my setup to have Meteor being the main server (app works fine), and then install Apache the serve my subdomain. The problem is I cannot have Apache serve on port 80 too since it seems to overrun my Meteor server.

From experience, I try to stay away from reverse-proxying Meteor, but I'm not knowledgeable enough to get Apache to dedicate itself to my subdomain and without overwhelming "everything port 80" on my server.

How can I have both services behave with each other in this kind of setup?


Update:

Following EasyEcho suggestion, I turned to using 2 different ip addresses.

Let it be known, I'm using a "Next Generation" Cloud server on Rackspace (running the latest Ubuntu 12.04 LTS with latest grub2/updated kernel.

Rackspace does not allow additional IPs on their Cloud Servers (source)...

The next generation Cloud Servers platform powered by OpenStack does not yet support additional IP addresses.

... but you get 1 IPv4 and 1 IPv6 when creating a server. So why not hop into the IPv6 bandwagon? Easier said than done.

So here is my "new problem": After mapping my subdomain to the IPv6 address (AAAA in DNS) and configuring Apache to listen to the IPv6 address, I get this following behavior:

From my server remote desktop (using freeNX), in Firefox

  • http:// [my:ip:v6:address] -> Apache (WIN)
  • http:// sub.domain.com -> Apache (WIN)
  • http:// my.ip.v4.address -> Meteor (WIN)
  • http:// main.domain.com -> Apache (FAIL)

From my workstation (Win7 x64), also in Firefox

  • http:// [my:ip:v6:address] -> The connection has timed out (FAIL)
  • http:// sub.domain.com -> Server not found (FAIL)
  • http:// my.ip.v4.address -> Meteor (WIN)
  • http:// main.domain.com -> Meteor (WIN)

Here is my Apache configuration:

/etc/apache2/ports.conf

NameVirtualHost [my:ip:v6:address]:80
Listen [my:ip:v6:address]:80

<IfModule mod_ssl.c>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

/etc/apache2/sites-enabled/default

<VirtualHost [my:ip:v6:address]:80>
    ServerAdmin webmaster@localhost

    ServerName sub.domain.com

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Can this be fixed to work as "advertised"?

share|improve this question
    
What is returned from "dig main.domain.com" on the remote ubuntu machine? –  EasyEcho Sep 6 '12 at 20:16
    
Thanks for your help!!! Just did the dig. Here are the results: pastebin.com/GPAdy2d2 –  kinologik Sep 6 '12 at 21:11
    
Also, I found a very interesting thread here: github.com/meteor/meteor/issues/159 - there might be a --binding=ip param in a future update of Meteor. Does not solve the problem in the "here and now", but nice to know I'm not alone with these kind of issues. –  kinologik Sep 6 '12 at 21:17

2 Answers 2

If possible assign multiple IPs to the machine and set Meteor to bind to 80 on one of the ips and Apache to bind to port 80 on the other. See Apache Documentation and Meteor Demo which seems to cover what you are looking for.


Update:

Well that is lots of new info...

You likely can't connect to the IPv6 ip/host from your workstation because you are on IPv4.

share|improve this answer
    
Excellent point! But I'm trying to avoid the multiple IPs solution... Also, this is the Meteor server I'm talking about: meteor.com/main Is there any other workaround beside going with multiple IPs? –  kinologik Sep 5 '12 at 20:30
    
Damn that is confusing. It isn't possible to bind multiple applications to the same port/ip combination. Whichever application grabs the port first based on start order will be the winner. Apache can also function as a proxy server as well so that could be an option to try. –  EasyEcho Sep 5 '12 at 20:34
    
Thank you very much for your feedback. Really appreciated. I'll try to proxy with Apache, but with the kind of results I got from Nginx, I'm a little skeptical... I'll post my result back here. –  kinologik Sep 5 '12 at 20:54
    
I have tried with 2 IP adresses, but got very strange results (see my update). –  kinologik Sep 6 '12 at 18:59

Hmm, you shouldn't need multiple IP addresses to do this.

Listen on 0.0.0.0:80 with something lightweight like NginX or HAProxy (scaling won't be a problem), and then reverse proxy the traffic through to the relevant layer underneath, running on a separate ports (listen on localhost, not 0.0.0.0).

So, request comes in for apache.your_domain.com, and HAProxy internally routes the traffic through to Apache running on another port.

Request comes in for meteor.your_domain.com, and HAProxy internally routes the traffic through to Node.js...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.