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

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:

127.0.0.1 myapp.vhost
127.0.0.1 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
</VirtualHost>

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

share|improve this question

1 Answer 1

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.

share|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? –  KayakJim Aug 1 '12 at 14:58

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.