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 want to point 2 URLs to the same rails app. Seems like it would be easy but it's not working!

The existing setup looks like this:

<VirtualHost *:80>
        DocumentRoot /home/some/path
        ServerName long_foo_name.com
        RewriteEngine On
        ProxyRequests Off
        ProxyPass / http://localhost:3000/
        ProxyPassReverse / http://localhost:3000/
        ProxyPreserveHost on
        AccessFileName .htaccess

         <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>
</VirtualHost>

I copied/pasted this and modified servername to the new servername (let's say "foo.com"). When I try going to foo.com, though, I get the default Fedora Test page. Apache error log shows "Directory index forbidden by Options directive" and rails logs aren't showing that the request is hitting rails.

The one caveat that may or may not be related is this. The second domain (in this case "foo.com") is a "leased" URL. Meaning. I don't actually own it and it's leased to me by the owner. When I ping the domain, the IP that's returned is actually different from my server.

But request to this domain ARE hitting my server (as shown by apache access logs). So it seems that requests to this domain are being proxied by their servers.

Could this proxying affect how Apache is handling the request?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

It does look like they're proxying. You can verify this by hitting the site and looking at the source IP -- if it's yours, then they're not proxying, they're doing something really weird, otherwise the source IP should be that of their proxy box. I would imagine that their proxying is probably doing all sorts of unpleasant things to the setup -- if the Host header being sent by their proxy server isn't what you're expecting, for instance, then that'll naturally cause problems. I always log the provided vhost name in my "default vhost" logs for this very reason -- it shows me what people might be hitting me from.

When it comes to the setup, I'd strongly recommend getting them to change the DNS to point to your server directly. That you're "leasing" the domain is irrelevant; DNS can still be managed properly. The only time proxying makes sense is if they're only redirecting part of the site to you, and serving other content on the same domain locally. For your Apache configuration, why are you setting up a whole separate vhost instead of just adding the second domain name as a ServerAlias on the existing vhost?

share|improve this answer
    
You were right. I looked at the headers of the actual requests and though the IP showing was mine, the Host header was being modified. The Host was set to the IP address instead of the actual host being requested. As a result, I had to map a VirtualHost to this IP address (actually this was in AWS so I had to map it to the internal IP address). Proxied requests suck. –  freshfunk Aug 11 '11 at 21:26
1  
@freshfunk As a better alternative to that workaround, tell them to get their act together and set the ProxyPreserveHost directive. –  Shane Madden Aug 11 '11 at 21:55
    
Thanks for the tip Shane. I realized how much the IP issue is giving me a headache (since I have other VirtualHosts on this machine). –  freshfunk Aug 12 '11 at 4:31
add comment

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.