I'm running the latest version of ubuntu, 12.04.

I'm trying to access my ruby on rails app via a faux domain, as specified in my /etc/hosts file: myapp.vhost www.myapp.vhost

and as far as apache goes, I've added my virtual host config:

<VirtualHost *:80>
    ServerName myapp.vhost
    ServerAlias *.myapp.vhost
    ProxyPass / http://localhost:3001/
    ProxyPassReverse / http://localhost:3001/
    ProxyPreserveHost on

to the file /etc/apache2/sites-available/myapp.conf

and in /etc/apache2/apache2.conf, I've added

Include sites-available/
Include sites-available/myapp.conf

to the bottom of the file.

I can restart apache, fin without error using this command:

sudo /etc/init.d/apache2 force-reload

The problem is that when I navigate to http://myapp.vhost in my browser, I get a 404 error.

What am I doing wrong here?

Note: My ruby on rails server is running on port 3001, with the -p3001 option of script/server


Remove the "Include sites-available/myapp.conf" line from /etc/apache2/apache2.conf and rename /etc/apache2/sites-available/myapp.conf to be /etc/apache2/sites-available/myapp (i.e. remove the '.conf' suffix).

Then issue sudo a2ensite myapp and then sudo service apache2 restart.

That should get you working.

You may also want to change your *ServerAlias .myapp.vhost line to be ServerAlias www.myapp.vhost and then try connecting to http://www.myapp.vhost since that is the entry in your /etc/hosts and not just the domain name.

| improve this answer | |
  • ok, just did all that, but browser gets 500 error, and the apache error log says [warn] proxy: No protocol handler was valid for the URL /favicon.ico. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. – NullVoxPopuli Jul 27 '12 at 17:39
  • Did you run "sudo a2enmod proxy_http" (sans quotes) and restart apache? – daemonofchaos Aug 1 '12 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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