You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Thibaut Lemaire <ti...@gmail.com> on 2013/04/02 18:18:56 UTC
[users@httpd] Problem with wildcard subdomains and ProxyPass
Hi,
I want to use Apache to proxy requests like domain.tld.MyDomain.tld to
domain.tld.
I've tried this :
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{HTTP_HOST} (.*).MyDomain.tld$
RewriteRule (.*).MyDomain.tld$ $1
ProxyPassMatch /http://$1/
</VirtualHost>
But of course it doesn't work.
I've tried many other solutions, but no one works.
Do you have an idea of the manner to resolve my problem ?
Thanks by advance,
Thibaut
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Problem with wildcard subdomains and ProxyPass
Posted by Thibaut Lemaire <ti...@gmail.com>.
Le 03/04/2013 11:34, Tom Evans a écrit :
> On Tue, Apr 2, 2013 at 9:18 PM, Thibaut Lemaire <ti...@gmail.com> wrote:
>> Le 02/04/2013 18:45, Tom Evans a écrit :
>>
>>> Do you mean proxy - you want to connect to a different server, fetch
>>> that content over the network to this server, and then deliver it to
>>> the client?
>>
>> Yes, it's what I want to do. Isn't it the good way ?
>>
> Oh, I see what you are trying to do now. You want to request
> 'facebook.com.mysite.com' and have apache proxy to 'facebook.com'.
>
> It would probably be easier to set up a real http proxy server and use
> that instead, almost certainly this approach will fail at some point.
> However - untested, but something like this should suffice:
>
> RewriteEngine on
> RewriteLog logs/rewrite.log
> RewriteLogLevel 5
> RewriteCond %{HTTP_HOST} (.*).MyDomain.tld$
> RewriteRule (.*) %1$1 [P]
>
>
> If it doesn't work, there will be some lovely debug information in
> logs/rewrite.log (relative to server root).
>
> Cheers
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
Thank you Tom, it's the manner we found and will use.
Have a good day,
Thibaut
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Problem with wildcard subdomains and ProxyPass
Posted by Tom Evans <te...@googlemail.com>.
On Tue, Apr 2, 2013 at 9:18 PM, Thibaut Lemaire <ti...@gmail.com> wrote:
>
> Le 02/04/2013 18:45, Tom Evans a écrit :
>
>> Do you mean proxy - you want to connect to a different server, fetch
>> that content over the network to this server, and then deliver it to
>> the client?
>
>
> Yes, it's what I want to do. Isn't it the good way ?
>
Oh, I see what you are trying to do now. You want to request
'facebook.com.mysite.com' and have apache proxy to 'facebook.com'.
It would probably be easier to set up a real http proxy server and use
that instead, almost certainly this approach will fail at some point.
However - untested, but something like this should suffice:
RewriteEngine on
RewriteLog logs/rewrite.log
RewriteLogLevel 5
RewriteCond %{HTTP_HOST} (.*).MyDomain.tld$
RewriteRule (.*) %1$1 [P]
If it doesn't work, there will be some lovely debug information in
logs/rewrite.log (relative to server root).
Cheers
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Problem with wildcard subdomains and ProxyPass
Posted by Thibaut Lemaire <ti...@gmail.com>.
Le 02/04/2013 18:45, Tom Evans a écrit :
> Do you mean proxy - you want to connect to a different server, fetch
> that content over the network to this server, and then deliver it to
> the client?
Yes, it's what I want to do. Isn't it the good way ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Problem with wildcard subdomains and ProxyPass
Posted by Tom Evans <te...@googlemail.com>.
On Tue, Apr 2, 2013 at 5:18 PM, Thibaut Lemaire <ti...@gmail.com> wrote:
> Hi,
>
> I want to use Apache to proxy requests like domain.tld.MyDomain.tld to
> domain.tld.
>
> I've tried this :
>
> <VirtualHost *:80>
> RewriteEngine on
> RewriteCond %{HTTP_HOST} (.*).MyDomain.tld$
> RewriteRule (.*).MyDomain.tld$ $1
> ProxyPassMatch /http://$1/
> </VirtualHost>
>
If you have a matching group in a RewriteCond, the match is available
in %N, not $N.
Capture in RewriteCond => %N
Capture in RewriteRule => $N
However, you can't use rewrite and mod_proxy like that. What you can
do is to use RewriteRule/Cond to generate a URL, and ask apache to
proxy to that URL by giving the RewriteRule a [P] flag (ie, no
ProxyPassMatch).
I'm still not sure what you are trying to do though.
Do you mean proxy - you want to connect to a different server, fetch
that content over the network to this server, and then deliver it to
the client?
Or do you want an internal rewrite - ask apache to internally request
this content from a different vhost hosted by this apache server?
Cheers
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org