Ask A Question

Notifications

You’re not receiving notifications from this thread.

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

spacerobotTR asked in Servers
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 webmaster@localhost.com
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 webmaster@localhost.com
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?
Reply
I ended up figuring it out. I had a typo in my 000-default.conf file that was causing the issue. 
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 79,047+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2023 GoRails, LLC. All rights reserved.