You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Felix Rubio <ch...@kngnt.org> on 2015/09/28 21:06:04 UTC

[users@httpd] VirtualHost configuration not working?

Hi everybody :-)

I have an Apache server (2.4) running on a Debian testing. Because I need to access some sites from Internet (iface 192.168.1.2)(with and without SSL), some others through a VPN (iface 10.8.0.1) and some others are purely local to the server (iface 127.0.0.2), I have created the following setup: 
ports.conf:
  Listen *:80
  Listen *:443
 
site external and internal (same .conf): 
  <VirtualHost 192.168.1.2:443>  --> SSL-enabled
  ServerName site0.example.org
  ....
  </VirtualHost>
  <VirtualHost 10.8.0.1:80>      --> Not SSL-enabled
  ServerName site0.example.org
  ....
  </VirtualHost>
 
site only internal (same .conf): 
  <VirtualHost 10.8.0.1:80>      --> Not SSL-enabled
  ServerName site1.example.org
  ....
  </VirtualHost>
 
site internal, external, and local (same .conf): 
  <VirtualHost 10.8.0.1:80 127.0.0.1:80>      --> Not SSL-enabled
  ServerName site2.example.org
  ....
  </VirtualHost>
  <VirtualHost 10.8.0.1:443 192.168.1.2:443>   --> SSL-enabled
  ServerName site2.example.org
  ....
  </VirtualHost>
 
The problem is: when I try to access the with any browser site1, I get in the address bar of the browser the URL from site0, and what is loaded is site2 (¿¿??). I have been searching for a solution for some days but I can not find my way through. Am I doing something dramatically wrong? Any help will be appreciated. Thanks!
Felix

Re: [users@httpd] VirtualHost configuration not working?

Posted by Marat Khalili <mk...@rqc.ru>.
I suspect something beyond virtualhost selection. Can you please:

1. Share more about the way site directories on server are specified. 
DocumentRoot, Alias'es, Redirect's etc.

2. Share access logs to make sure Apache is accessing same virtualhosts 
we think it is accessing. :)

Also, is it possible that sites-enabled directory is not populated 
properly, or not included in apache2.conf? And, have you tried to fully 
stop and start Apache again (not just restart gracefully)? Clearing 
browser caches and force-reloading pages may also help. Make sure no 
proxy is configured in either Firefox (that has independent proxy 
settings) or system. There're no transparent proxies and reverse proxies 
in your network, are there?

It's obvious, but sometimes it helps to try reproduce your configuration 
on a clean Apache installation (since issue is observed for HTTP too, no 
need to configure SSL part).

-- 

With Best Regards,
Marat Khalili

On 29/09/15 21:07, Felix Rubio Dalmau wrote:
>
> Hi Marat, httpd-users :)
>
> I have updated the configuration of my apache. Following these lines 
> there is the updated version. The behavior now is:
>
> a) If I type in the url box the non-ssl address of site1 IN FIREFOX, 
> It gets transformed into the ssl address of site0, and its content is 
> loaded. No entries in error log, neither in site1 or site0 logs.
>
> b) If I type in the url box the non-ssl addres of site1 IN KONQUEROR, 
> the index.html file for site1 is loaded (without any styles) and an 
> entry in error.log in apache is created, pointing to a file that can 
> not be accessed... Because although it belongs to site1, it is being 
> searched for in /srv/site0/... !!!!!!
>
> This is becoming more and more strange on a per-second basis :S
>
> Thank you!
>
> ports.conf:
>
> Listen 80
>
> Listen 443
>
> 000-default sites (same .conf) (a catch-all for everything not falling 
> in any other site's specs).
>
> <VirtualHost *:80> --> Not SSL-enabled
>
> ....
>
> </VirtualHost>
>
> <VirtualHost *:443> --> SSL-enabled
>
> ....
>
> </VirtualHost>
>
> Site external and internal (same .conf):
>
> <VirtualHost 192.168.1.2:443> --> SSL-enabled
>
> ServerName site0.example.org
>
> ....
>
> </VirtualHost>
>
> <VirtualHost 10.8.0.1:80> --> Not SSL-enabled
>
> ServerName site0.example.org
>
> ....
>
> </VirtualHost>
>
> site only internal (same .conf):
>
> <VirtualHost 10.8.0.1:80> --> Not SSL-enabled
>
> ServerName site1.example.org
>
> ....
>
> </VirtualHost>
>
> site internal, external, and local (same .conf):
>
> <VirtualHost 10.8.0.1:80 127.0.0.1:80> --> Not SSL-enabled
>
> ServerName site2.example.org
>
> ....
>
> </VirtualHost>
>
> <VirtualHost 10.8.0.1:443 192.168.1.2:443> --> SSL-enabled
>
> ServerName site2.example.org
>
> ....
>
> </VirtualHost>
>
> On Tuesday 29 September 2015 16:12:23 Marat Khalili wrote:
>
> > This is very strange. Even when Apache cannot determine request host
>
> > name, it loads the first defined virtual host, not the last one. I
>
> > wonder, in your case, what will it load if you disable last two virtual
>
> > host records?
>
> >
>
> > (BTW, it's usually either Listen 80, or Listen specific-ip:80, but I
>
> > don't think it causes your issue.)
>
> >
>


Re: [users@httpd] VirtualHost configuration not working?

Posted by Yann Ylavic <yl...@gmail.com>.
Hi,

can you provide the output of "apachectl -S"?
You may hide real names with site1, site2, ... but please keep one
name per orinal name.

Regards,
Yann.


On Tue, Sep 29, 2015 at 8:07 PM, Felix Rubio Dalmau
<fe...@gmail.com> wrote:
> Hi Marat, httpd-users :)
>
>
>
> I have updated the configuration of my apache. Following these lines there
> is the updated version. The behavior now is:
>
>
>
> a) If I type in the url box the non-ssl address of site1 IN FIREFOX, It gets
> transformed into the ssl address of site0, and its content is loaded. No
> entries in error log, neither in site1 or site0 logs.
>
> b) If I type in the url box the non-ssl addres of site1 IN KONQUEROR, the
> index.html file for site1 is loaded (without any styles) and an entry in
> error.log in apache is created, pointing to a file that can not be
> accessed... Because although it belongs to site1, it is being searched for
> in /srv/site0/... !!!!!!
>
>
>
> This is becoming more and more strange on a per-second basis :S
>
> Thank you!
>
>
>
> ports.conf:
>
> Listen 80
>
> Listen 443
>
>
>
> 000-default sites (same .conf) (a catch-all for everything not falling in
> any other site's specs).
>
> <VirtualHost *:80> --> Not SSL-enabled
>
> ....
>
> </VirtualHost>
>
> <VirtualHost *:443> --> SSL-enabled
>
> ....
>
> </VirtualHost>
>
>
>
> Site external and internal (same .conf):
>
> <VirtualHost 192.168.1.2:443> --> SSL-enabled
>
> ServerName site0.example.org
>
> ....
>
> </VirtualHost>
>
> <VirtualHost 10.8.0.1:80> --> Not SSL-enabled
>
> ServerName site0.example.org
>
> ....
>
> </VirtualHost>
>
> site only internal (same .conf):
>
> <VirtualHost 10.8.0.1:80> --> Not SSL-enabled
>
> ServerName site1.example.org
>
> ....
>
> </VirtualHost>
>
> site internal, external, and local (same .conf):
>
> <VirtualHost 10.8.0.1:80 127.0.0.1:80> --> Not SSL-enabled
>
> ServerName site2.example.org
>
> ....
>
> </VirtualHost>
>
> <VirtualHost 10.8.0.1:443 192.168.1.2:443> --> SSL-enabled
>
> ServerName site2.example.org
>
> ....
>
> </VirtualHost>
>
>
>
> On Tuesday 29 September 2015 16:12:23 Marat Khalili wrote:
>
>> This is very strange. Even when Apache cannot determine request host
>
>> name, it loads the first defined virtual host, not the last one. I
>
>> wonder, in your case, what will it load if you disable last two virtual
>
>> host records?
>
>>
>
>> (BTW, it's usually either Listen 80, or Listen specific-ip:80, but I
>
>> don't think it causes your issue.)
>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] VirtualHost configuration not working?

Posted by Felix Rubio Dalmau <fe...@gmail.com>.
Hi Marat, httpd-users :)

	I have updated the configuration of my apache. Following these lines there is the updated version. The behavior now is:

	a) If I type in the url box the non-ssl address of site1 IN FIREFOX, It gets transformed into the ssl address of site0, and its content is loaded. No entries in error log, neither in site1 or site0 logs.
	b) If I type in the url box the non-ssl addres of site1 IN KONQUEROR, the index.html file for site1 is loaded (without any styles) and an entry in error.log in apache is created, pointing to a file that can not be accessed... Because although it belongs to site1, it is being searched for in /srv/site0/... !!!!!!

	This is becoming more and more strange on a per-second basis :S
	
	Thank you!

ports.conf:
  Listen 80
  Listen 443

000-default sites (same .conf) (a catch-all for everything not falling in any other site's specs).
  <VirtualHost *:80>      --> Not SSL-enabled
  ....
  </VirtualHost>
  <VirtualHost *:443>      --> SSL-enabled
  ....
  </VirtualHost>

Site external and internal (same .conf): 
  <VirtualHost 192.168.1.2:443>  --> SSL-enabled
  ServerName site0.example.org
  ....
  </VirtualHost>
  <VirtualHost 10.8.0.1:80>      --> Not SSL-enabled
  ServerName site0.example.org
  ....
  </VirtualHost>
 
site only internal (same .conf): 
  <VirtualHost 10.8.0.1:80>      --> Not SSL-enabled
  ServerName site1.example.org
  ....
  </VirtualHost>
 
site internal, external, and local (same .conf): 
  <VirtualHost 10.8.0.1:80 127.0.0.1:80>      --> Not SSL-enabled
  ServerName site2.example.org
  ....
  </VirtualHost>
  <VirtualHost 10.8.0.1:443 192.168.1.2:443>   --> SSL-enabled
  ServerName site2.example.org
  ....
  </VirtualHost>

On Tuesday 29 September 2015 16:12:23 Marat Khalili wrote:
> This is very strange. Even when Apache cannot determine request host 
> name, it loads the first defined virtual host, not the last one. I 
> wonder, in your case, what will it load if you disable last two virtual 
> host records?
> 
> (BTW, it's usually either Listen 80, or Listen specific-ip:80, but I 
> don't think it causes your issue.)
> 


Re: [users@httpd] VirtualHost configuration not working?

Posted by Marat Khalili <mk...@rqc.ru>.
This is very strange. Even when Apache cannot determine request host 
name, it loads the first defined virtual host, not the last one. I 
wonder, in your case, what will it load if you disable last two virtual 
host records?

(BTW, it's usually either Listen 80, or Listen specific-ip:80, but I 
don't think it causes your issue.)

-- 

With Best Regards,
Marat Khalili

On 29/09/15 15:49, felix rubio dalmau wrote:
> Hi,
>   No, the reason is that site2 holds a cardav server, that is accessed 
> by other of the sites on the same host. The idea behind this is that I 
> can save all the time spent in encryption (the SSL layer) if I know 
> that both sites are local.
>
>   I am testing this configuration from a client on the VPN (10.8.0.6).
>   Thank you!
>
> On Tue, Sep 29, 2015 at 5:57 AM, Marat Khalili <mkh@rqc.ru 
> <ma...@rqc.ru>> wrote:
>
>     Hello,
>
>     127.0.0.1 <http://127.0.0.1> is only configured for site2 -- is it
>     a bug or a feature? Are you testing it from the same host, or via
>     proxy on the same host?
>     -- 
>
>     With Best Regards,
>     Marat Khalili
>
>
>     On September 28, 2015 10:06:04 PM GMT+03:00, Felix Rubio
>     <chronos@kngnt.org <ma...@kngnt.org>> wrote:
>
>         Hi everybody :-)
>
>         I have an Apache server (2.4) running on a Debian testing.
>         Because I need to access some sites from Internet (iface
>         192.168.1.2)(with and without SSL), some others through a VPN
>         (iface 10.8.0.1) and some others are purely local to the
>         server (iface 127.0.0.2), I have created the following setup:
>
>         ports.conf:
>
>         Listen *:80
>
>         Listen *:443
>
>         site external and internal (same .conf):
>
>         <VirtualHost 192.168.1.2:443 <http://192.168.1.2:443>> -->
>         SSL-enabled
>
>         ServerName site0.example.org <http://site0.example.org>
>
>         ....
>
>         </VirtualHost>
>
>         <VirtualHost 10.8.0.1:80 <http://10.8.0.1:80>> --> Not SSL-enabled
>
>         ServerName site0.example.org <http://site0.example.org>
>
>         ....
>
>         </VirtualHost>
>
>         site only internal (same .conf):
>
>         <VirtualHost 10.8.0.1:80 <http://10.8.0.1:80>> --> Not SSL-enabled
>
>         ServerName site1.example.org <http://site1.example.org>
>
>         ....
>
>         </VirtualHost>
>
>         site internal, external, and local (same .conf):
>
>         <VirtualHost 10.8.0.1:80 <http://10.8.0.1:80> 127.0.0.1:80
>         <http://127.0.0.1:80>> --> Not SSL-enabled
>
>         ServerName site2.example.org <http://site2.example.org>
>
>         ....
>
>         </VirtualHost>
>
>         <VirtualHost 10.8.0.1:443 <http://10.8.0.1:443>
>         192.168.1.2:443 <http://192.168.1.2:443>> --> SSL-enabled
>
>         ServerName site2.example.org <http://site2.example.org>
>
>         ....
>
>         </VirtualHost>
>
>         The problem is: when I try to access the with any browser
>         site1, I get in the address bar of the browser the URL from
>         site0, and what is loaded is site2 (¿¿??). I have been
>         searching for a solution for some days but I can not find my
>         way through. Am I doing something dramatically wrong? Any help
>         will be appreciated. Thanks!
>
>         Felix
>
>


Re: [users@httpd] VirtualHost configuration not working?

Posted by felix rubio dalmau <fe...@gmail.com>.
Hi,
  No, the reason is that site2 holds a cardav server, that is accessed by
other of the sites on the same host. The idea behind this is that I can
save all the time spent in encryption (the SSL layer) if I know that both
sites are local.

  I am testing this configuration from a client on the VPN (10.8.0.6).
  Thank you!

On Tue, Sep 29, 2015 at 5:57 AM, Marat Khalili <mk...@rqc.ru> wrote:

> Hello,
>
> 127.0.0.1 is only configured for site2 -- is it a bug or a feature? Are
> you testing it from the same host, or via proxy on the same host?
> --
>
> With Best Regards,
> Marat Khalili
>
>
> On September 28, 2015 10:06:04 PM GMT+03:00, Felix Rubio <
> chronos@kngnt.org> wrote:
>>
>> Hi everybody :-)
>>
>>
>>
>> I have an Apache server (2.4) running on a Debian testing. Because I need
>> to access some sites from Internet (iface 192.168.1.2)(with and without
>> SSL), some others through a VPN (iface 10.8.0.1) and some others are purely
>> local to the server (iface 127.0.0.2), I have created the following setup:
>>
>> ports.conf:
>>
>> Listen *:80
>>
>> Listen *:443
>>
>> site external and internal (same .conf):
>>
>> <VirtualHost 192.168.1.2:443> --> SSL-enabled
>>
>> ServerName site0.example.org
>>
>> ....
>>
>> </VirtualHost>
>>
>> <VirtualHost 10.8.0.1:80> --> Not SSL-enabled
>>
>> ServerName site0.example.org
>>
>> ....
>>
>> </VirtualHost>
>>
>> site only internal (same .conf):
>>
>> <VirtualHost 10.8.0.1:80> --> Not SSL-enabled
>>
>> ServerName site1.example.org
>>
>> ....
>>
>> </VirtualHost>
>>
>> site internal, external, and local (same .conf):
>>
>> <VirtualHost 10.8.0.1:80 127.0.0.1:80> --> Not SSL-enabled
>>
>> ServerName site2.example.org
>>
>> ....
>>
>> </VirtualHost>
>>
>> <VirtualHost 10.8.0.1:443 192.168.1.2:443> --> SSL-enabled
>>
>> ServerName site2.example.org
>>
>> ....
>>
>> </VirtualHost>
>>
>> The problem is: when I try to access the with any browser site1, I get in
>> the address bar of the browser the URL from site0, and what is loaded is
>> site2 (¿¿??). I have been searching for a solution for some days but I can
>> not find my way through. Am I doing something dramatically wrong? Any help
>> will be appreciated. Thanks!
>>
>> Felix
>>
>

Re: [users@httpd] VirtualHost configuration not working?

Posted by Marat Khalili <mk...@rqc.ru>.
Hello,

127.0.0.1 is only configured for site2 -- is it a bug or a feature? Are you testing it from the same host, or via proxy on the same host?
-- 

With Best Regards,
Marat Khalili

On September 28, 2015 10:06:04 PM GMT+03:00, Felix Rubio <ch...@kngnt.org> wrote:
>Hi everybody :-)
>
>I have an Apache server (2.4) running on a Debian testing. Because I
>need to access some sites from Internet (iface 192.168.1.2)(with and
>without SSL), some others through a VPN (iface 10.8.0.1) and some
>others are purely local to the server (iface 127.0.0.2), I have created
>the following setup: 
>ports.conf:
>  Listen *:80
>  Listen *:443
> 
>site external and internal (same .conf): 
>  <VirtualHost 192.168.1.2:443>  --> SSL-enabled
>  ServerName site0.example.org
>  ....
>  </VirtualHost>
>  <VirtualHost 10.8.0.1:80>      --> Not SSL-enabled
>  ServerName site0.example.org
>  ....
>  </VirtualHost>
> 
>site only internal (same .conf): 
>  <VirtualHost 10.8.0.1:80>      --> Not SSL-enabled
>  ServerName site1.example.org
>  ....
>  </VirtualHost>
> 
>site internal, external, and local (same .conf): 
>  <VirtualHost 10.8.0.1:80 127.0.0.1:80>      --> Not SSL-enabled
>  ServerName site2.example.org
>  ....
>  </VirtualHost>
>  <VirtualHost 10.8.0.1:443 192.168.1.2:443>   --> SSL-enabled
>  ServerName site2.example.org
>  ....
>  </VirtualHost>
> 
>The problem is: when I try to access the with any browser site1, I get
>in the address bar of the browser the URL from site0, and what is
>loaded is site2 (¿¿??). I have been searching for a solution for some
>days but I can not find my way through. Am I doing something
>dramatically wrong? Any help will be appreciated. Thanks!
>Felix