Skip to main content

Issue with multiple URL's on an Ubuntu/Apache2/Passenger machine

Servers • Asked by spacerobotTR
I have a linux machine that I put together within my organization for Rails applications. I have my first site all set up and working. I am now trying to add a second site/URL to the box and for some reason both URL's hit the first site that I put up. Here is my apache2 site.conf file:

Listen 80
Listen 8080

<VirtualHost *:80>
PassengerRuby /home/user/.rbenv/shims/ruby
ServerName mysite.com
ServerAlias site1.com
ServerAdmin [email protected]
RailsEnv production
DocumentRoot /home/user/rails/site1/public/
ErrorLog /home/user/rails/site1/log/error.log
CustomLog /homeuser/rails/site1/log/access.log combined
<Directory "/home/user/rails/site1/public/">
    Options FollowSymLinks
    Require ip 111.111.0.0/16
    Options -MultiViews
</Directory>

<LocationMatch "/home/user/rails/site1/public">
  order deny,allow
  deny from all
  allow from 111.111.0.0/16
</LocationMatch>

<VirtualHost *:8080>
PassengerRuby /home/user/.rbenv/shims/ruby
ServerName mysite2.com
ServerAlias site2.com
ServerAdmin [email protected]
RailsEnv production
DocumentRoot /home/user/rails/site2/public/
ErrorLog /home/user/rails/site2/log/error.log
CustomLog /home/user/rails/site2/log/access.log combined
<Directory "/home/user/rails/site2/public/">
    Options FollowSymLinks
    Require ip 111.111.0.0/16
    Options -MultiViews
</Directory>

<LocationMatch "/home/user/rails/site2/public">
  order deny,allow
  deny from all
  allow from 111.111.0.0/16
</LocationMatch>

This is my hosts file:

127.0.1 Localhost
127.0.1.1:80 site1.com
127.0.2.1:8080 site2.com

Both URLs display the content for site1.com

What am I missing here?

I ended up figuring it out. I had a typo in my 000-default.conf file that was causing the issue. 

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 24,647+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.