You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Rocco Scappatura <Ro...@infracom.it> on 2009/04/29 19:22:23 UTC

[users@httpd]

Hello,

I ve an Apache2.2+Tomcat5.5+Windows2K platform.

I use Apache2.2 to proxy almost all the requests for 80 port of my server
(http://www.mysite.it).

Since some days I would like to setup an Apache2.2 virtual host to show
the content of a site directly through Apache2.2 (i.e.: not proxying the
requests for the site - say http://www.virtualhost.it - to Tomcat).

It should be quite simple to set this up in httpd.conf:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

and in httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.it
    DocumentRoot "C:/Apache2.2/htdocs/virtualhost2"
    ServerName virtualhost.mysite.it
    ErrorLog "logs/virtualhost.mysite.it-error_log"
    CustomLog "logs/virtualhost.mysite.it-access_log" common
</VirtualHost>

But after reload apache service and I try to access to
http://www.virtualhost.it I get the content of http://www.mysite.it.

Basically it happens that the request for http://www.mysite.it is seen by
Apache as a request for / and so proxied to Tomcat.

How could I solve this issue?

Below I ve reported the mod_proxy configuration..

Thanks in advance,

rocsca

<IfModule mod_proxy.c>
	ProxyHTMLLogVerbose On
	LogLevel Debug

	ProxyRequests off

	ProxyPass /blog/ http://localhost:8081/roller/blog/
	ProxyPassReverse /blog/ http://localhost:8081/roller/blog/
	ProxyHTMLURLMap  http://www.domain.it/roller/blog/ /blog/
	ProxyHTMLURLMap  http://localhost:8081/roller/blog/ /blog/

	<Location /blog/ >
		SetOutputFilter  proxy-html
		ProxyHTMLURLMap  /roller/blog/ /blog/
		ProxyHTMLURLMap  /blog /blog
		RequestHeader    unset  Accept-Encoding
	</Location>

	ProxyPass /roller/ http://localhost:8081/roller/
	ProxyPassReverse /roller/ http://localhost:8081/roller/
	ProxyHTMLURLMap  http://www.domain.it/roller/ /roller/
	ProxyHTMLURLMap  http://localhost:8081/roller/ /roller/

	ProxyPass /path1/file1 !
	ProxyPass /virtualhost !
	ProxyPass /path2/ !
	ProxyPass /path3/ !
	ProxyPass / http://localhost:8081/domain/
	ProxyPassReverse / http://localhost:8081/domain/

	<Location / >
		SetOutputFilter  proxy-html
		ProxyHTMLURLMap /domain/ /
		RequestHeader    unset  Accept-Encoding
	</Location>
</IfModule>



---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd]

Posted by André Warnier <aw...@ice-sa.com>.
Rocco Scappatura wrote:
> Hello,
> 
> On Gio, 30 Aprile 2009 15:44, André Warnier wrote:
> 
>>> So I think that the header Host: is considered after mod_proxy and so
>>> the
>>> request is forwarded to Tomcat.
>>>
>> With respect, I think that this does not make sense.
>> Apache has to first parse the Host: header, before it even knows which
>> <VirtualHost> should handle the request.  So it can certainly not apply
>> any specific VirtualHost section directive before it has read and
>> understood this header.
> 
> OK. Infact, I agree with you.. :-)
> 
> I really figure out why I don't see the content of document root specified
> forthe virtual host.. :-( After all the access and errorlogs for the
> specified virtual ho are created..
> 
Difficult to say without having access to your /complete/ configuration, 
and without looking at the access and error logs.

Arm yourself seriously for debugging, and don't make too many guesses 
before you have some real data.  Don't change too much at a time in your 
configuration, or you will not know which is which anymore.
Start from a config that works, make one change and test.

Give each virtualhost section its own access log and error log.
If you use mod_rewrite, turn on its log too.

Then access your site once and look at the logs.

Access log tells you what it tried to access, and a code 200 if it was 
ok, another code it was not.
The error log will tell you why it was not.
If you don't even get a line in the access log, it means that the 
request did not even reach the server.

Use "nslookup" to verify that both your hostnames resolve to the same 
IP, and that it is the IP of your server.

The first defined <VirtualHost> section acts as the default virtualhost, 
so all calls where Apache cannot identify the target host will end up there.

If you need to see really what the server is sending in return to the 
browser, get an appropriate plugin :
- HttpFox for Firefox
- Fiddler2 for IE
- .. ?

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd]

Posted by Rocco Scappatura <Ro...@infracom.it>.
Hello,

On Gio, 30 Aprile 2009 15:44, André Warnier wrote:

>> So I think that the header Host: is considered after mod_proxy and so
>> the
>> request is forwarded to Tomcat.
>>
> With respect, I think that this does not make sense.
> Apache has to first parse the Host: header, before it even knows which
> <VirtualHost> should handle the request.  So it can certainly not apply
> any specific VirtualHost section directive before it has read and
> understood this header.

OK. Infact, I agree with you.. :-)

I really figure out why I don't see the content of document root specified
forthe virtual host.. :-( After all the access and errorlogs for the
specified virtual ho are created..

Any idea?

rocsca


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd]

Posted by André Warnier <aw...@ice-sa.com>.
Rocco Scappatura wrote:
> Thanks Karel for your answer.
> 
> On Mer, 29 Aprile 2009 19:34, Karel Kubat wrote:
>>> <VirtualHost *:80>
>>>    ServerAdmin webmaster@mysite.it
>>>    DocumentRoot "C:/Apache2.2/htdocs/virtualhost2"
>>>    ServerName virtualhost.mysite.it
>>>    ErrorLog "logs/virtualhost.mysite.it-error_log"
>>>    CustomLog "logs/virtualhost.mysite.it-access_log" common
>>> </VirtualHost>
>>>
> 
> I forgot to mention the default virtual host just before the one above
> that is sit in my virtual host conf file:
> 
> <VirtualHost *:80>
> 	ServerName www.mysite.it
> 	DocumentRoot "C:/Apache2.2/htdocs"
> </VirtualHost>
> 
>> Please read http://httpd.apache.org/docs/2.2/vhosts/name-based.html
>> Basically you will need two virtual hosts listening to *:80. The first
>> one must have a ServerAlias www.mysite.it and the second one
>> virtualhost.mysite.it.
>>
>> That should do the trick.
> 
> Anyway I added the ServerAlias directive as well but nothing of good has
> happened.. :-(
> 
> Please read what I report below again (I think that this is the key of the
> mistake):
> 
>>> Basically it happens that the request for http://www.virtualhost.it is
>>> seen by
>>> Apache as a request for / (no matter what is the virtual host) and so
> proxied to Tomcat.
> 
> So I think that the header Host: is considered after mod_proxy and so the
> request is forwarded to Tomcat.
> 
With respect, I think that this does not make sense.
Apache has to first parse the Host: header, before it even knows which 
<VirtualHost> should handle the request.  So it can certainly not apply 
any specific VirtualHost section directive before it has read and 
understood this header.

Think of another scenario to confirm/deny.
;-)



---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd]

Posted by Rocco Scappatura <Ro...@infracom.it>.
Thanks Karel for your answer.

On Mer, 29 Aprile 2009 19:34, Karel Kubat wrote:
>> <VirtualHost *:80>
>>    ServerAdmin webmaster@mysite.it
>>    DocumentRoot "C:/Apache2.2/htdocs/virtualhost2"
>>    ServerName virtualhost.mysite.it
>>    ErrorLog "logs/virtualhost.mysite.it-error_log"
>>    CustomLog "logs/virtualhost.mysite.it-access_log" common
>> </VirtualHost>
>>

I forgot to mention the default virtual host just before the one above
that is sit in my virtual host conf file:

<VirtualHost *:80>
	ServerName www.mysite.it
	DocumentRoot "C:/Apache2.2/htdocs"
</VirtualHost>

> Please read http://httpd.apache.org/docs/2.2/vhosts/name-based.html
> Basically you will need two virtual hosts listening to *:80. The first
> one must have a ServerAlias www.mysite.it and the second one
> virtualhost.mysite.it.
>
> That should do the trick.

Anyway I added the ServerAlias directive as well but nothing of good has
happened.. :-(

Please read what I report below again (I think that this is the key of the
mistake):

>> Basically it happens that the request for http://www.virtualhost.it is
>> seen by
>> Apache as a request for / (no matter what is the virtual host) and so
proxied to Tomcat.

So I think that the header Host: is considered after mod_proxy and so the
request is forwarded to Tomcat.

Could someone confirm this scenario?

thanks,

rocsca


---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd]

Posted by Karel Kubat <ka...@e-tunity.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

On Apr 29, 2009, at 7:22 PM, Rocco Scappatura wrote:

> Hello,
>
> I ve an Apache2.2+Tomcat5.5+Windows2K platform.
>
> I use Apache2.2 to proxy almost all the requests for 80 port of my  
> server
> (http://www.mysite.it).
>
> Since some days I would like to setup an Apache2.2 virtual host to  
> show
> the content of a site directly through Apache2.2 (i.e.: not proxying  
> the
> requests for the site - say http://www.virtualhost.it - to Tomcat).
>
> It should be quite simple to set this up in httpd.conf:
>
> # Virtual hosts
> Include conf/extra/httpd-vhosts.conf
>
> and in httpd-vhosts.conf:
>
> <VirtualHost *:80>
>    ServerAdmin webmaster@mysite.it
>    DocumentRoot "C:/Apache2.2/htdocs/virtualhost2"
>    ServerName virtualhost.mysite.it
>    ErrorLog "logs/virtualhost.mysite.it-error_log"
>    CustomLog "logs/virtualhost.mysite.it-access_log" common
> </VirtualHost>
>
> But after reload apache service and I try to access to
> http://www.virtualhost.it I get the content of http://www.mysite.it.
>
> Basically it happens that the request for http://www.mysite.it is  
> seen by
> Apache as a request for / and so proxied to Tomcat.

[snip snip]

Please read http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Basically you will need two virtual hosts listening to *:80. The first  
one must have a ServerAlias www.mysite.it and the second one  
virtualhost.mysite.it.

That should do the trick.
- --
Best regards / met vriendelijke groet, Karel Kubat
Mob +31 6 2956 4861

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAkn4j70ACgkQ23FrzRzybNXqlwCg4+lEbi/vW4SZ8QXoIvbHOiiF
zWgAoPeyLF/Q4VCpuKQRVxTmab88IqGB
=a9kI
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org