Re: alias using Virtual host

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Melanie Pfefer wrote:
Hi,

Let me clarify more:

I have the main http.conf file and created another http.conf to run another apache instance on port 8094.

That is a welcome clarification indeed.
Why t.h. did you do that for ? ;-)

You could also do that with a single Apache.
So, before we go any further, which solution do you prefer ? one or two Apaches ?

Then, if you choose to have two, for further clarification I suggest that in future messages, you name them like "A" or "B".


I then created a DNS alias (let’s say called alias2) and put these lines


Where ? in which of your Apache's ?

NameVirtualHost *:80

<VirtualHost *:80>
        ServerName alias2
        ProxyPass / http://localhost: 8094/
        ProxyPassReverse / http://localhost: 8094/
</VirtualHost>


Independently of what happens in the future
(and I am now talking about "Apache A") :

If the above <VirtualHost> section is *the only one* (or the first one) you have in that particular Apache instance, then it acts as the "default host" (and yes it will also catch all calls to "http://host";).
If you don't want that, then do as follows :

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName whatever
  DocumentRoot /wherever
.. other configuration lines belonging to what you want http://host to be like
...
</VirtualHost>

<VirtualHost *:80>
         ServerName alias2
         ProxyPass / http://localhost: 8094/
         ProxyPassReverse / http://localhost: 8094/
</VirtualHost>

In other words, now the first <VirtualHost> section above (because it is the first) becomes your default VirtualHost. Only requests that specifically name "alias2" will be handled by the second <VirtualHost> section (and thus proxied to the other server on port 8094). All other requests (including the ones addressed to "http://host"; will be handled by the first section, which does not proxy. That is because it is now the default VirtualHost. That is also why the "ServerName" you put in that one, does not matter, because it will catch all requests that are not for "alias2" anyway, as long as they arrive to your server.


Next if you want, we will see how you can combine these two Apache's into a single one, using the same logic.



This previously worked like a charm on a server where apache was running on port 80.

With respect, I kind of doubt that.

I suspect that this time, the aliasing is not working perhaps because apache has:

Listen 8088 and
Listen 80

In the config file.


No. It has nothing to do with that.


This is the only difference.


With the configuration above, on the current system, http://host and http://alias2 go to http://host:8094 while I want only http://alias2 to go to http://host:8094.


Yes, and do you now understand why ?
If not, go ahead and re-read http://httpd.apache.org/docs/2.2/vhosts/name-based.html


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux