You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by David Tkacik <dt...@healthcoachinstitute.com> on 2018/09/24 15:14:41 UTC
[users@httpd] Rewrite with proxy adds document root
I have this config included via Include conf.d/myconfig/*.conf within my virtualhost.
<Location "/requested-uri">
ProxyAddHeaders off
RewriteEngine on
RewriteCond %{QUERY_STRING} ^123 [NC]
RequestHeader set "X-API-KEY" "proxied"
RewriteRule (.*) "https://${HOST}$1" [QSD,P,L]
</Location>
But the above rule is also proxying the /var/www/html which is the document root. I have no idea why as this is not added via .htaccess
So if you curl for example /requested-uri/123/index.html the proxied path would look /var/www/html/requested-uri/123/index.html
Any ideas why ?
Thanks a lot !
Re: [users@httpd] Rewrite with proxy adds document root
Posted by Eric Covener <co...@gmail.com>.
On Mon, Sep 24, 2018 at 11:46 AM David Tkacik
<dt...@healthcoachinstitute.com> wrote:
>
> Thanks Eric,
>
> But if I have multiple rewrite rules and rewrite conditions, how do I speficy for which cond and rule I want to apply it in context of a URI ?
>
> Would waterfall work here ?
>
> For example in one config:
>
> RewriteCond %{QUERY_STRING} ^123 [NC]
> RequestHeader set "X-API-KEY" "proxied"
> RewriteRule ^/123/(.*) "https://${HOST}$1" [QSD,P,L]
>
> RewriteCond %{QUERY_STRING} ^456 [NC]
> RequestHeader set "X-API-KEY” “different-api-key"
> RewriteRule ^/456/(.*) "https://${HOST}$1" [QSD,P,L]
>
> Thanks !
The conditions are automatically only applied to the RewriteRule that
they precede. And the RewriteRule can already match against the URI.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Rewrite with proxy adds document root
Posted by David Tkacik <dt...@healthcoachinstitute.com>.
Thanks Eric,
But if I have multiple rewrite rules and rewrite conditions, how do I speficy for which cond and rule I want to apply it in context of a URI ?
Would waterfall work here ?
For example in one config:
RewriteCond %{QUERY_STRING} ^123 [NC]
RequestHeader set "X-API-KEY" "proxied"
RewriteRule ^/123/(.*) "https://${HOST}$1" [QSD,P,L]
RewriteCond %{QUERY_STRING} ^456 [NC]
RequestHeader set "X-API-KEY” “different-api-key"
RewriteRule ^/456/(.*) "https://${HOST}$1" [QSD,P,L]
Thanks !
> On 24 Sep 2018, at 16:28, Eric Covener <co...@gmail.com> wrote:
>
> On Mon, Sep 24, 2018 at 11:14 AM David Tkacik
> <dt...@healthcoachinstitute.com> wrote:
>>
>> I have this config included via Include conf.d/myconfig/*.conf within my virtualhost.
>>
>> <Location "/requested-uri">
>> ProxyAddHeaders off
>> RewriteEngine on
>> RewriteCond %{QUERY_STRING} ^123 [NC]
>> RequestHeader set "X-API-KEY" "proxied"
>> RewriteRule (.*) "https://${HOST}$1" [QSD,P,L]
>> </Location>
>>
>> But the above rule is also proxying the /var/www/html which is the document root. I have no idea why as this is not added via .htaccess
>>
>> So if you curl for example /requested-uri/123/index.html the proxied path would look /var/www/html/requested-uri/123/index.html
>>
>> Any ideas why ?
>>
>> Thanks a lot !
>
> It's best to avoid Rewrite inside <Location>. You could simply match
> the URL's you want to match in the first arg of the rewriterule.
>
>
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
Re: [users@httpd] Rewrite with proxy adds document root
Posted by Eric Covener <co...@gmail.com>.
On Mon, Sep 24, 2018 at 11:14 AM David Tkacik
<dt...@healthcoachinstitute.com> wrote:
>
> I have this config included via Include conf.d/myconfig/*.conf within my virtualhost.
>
> <Location "/requested-uri">
> ProxyAddHeaders off
> RewriteEngine on
> RewriteCond %{QUERY_STRING} ^123 [NC]
> RequestHeader set "X-API-KEY" "proxied"
> RewriteRule (.*) "https://${HOST}$1" [QSD,P,L]
> </Location>
>
> But the above rule is also proxying the /var/www/html which is the document root. I have no idea why as this is not added via .htaccess
>
> So if you curl for example /requested-uri/123/index.html the proxied path would look /var/www/html/requested-uri/123/index.html
>
> Any ideas why ?
>
> Thanks a lot !
It's best to avoid Rewrite inside <Location>. You could simply match
the URL's you want to match in the first arg of the rewriterule.
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org