Re: [users@httpd] configuring a proxy fallback

2018-05-21 Thread John Bazik
> OK, was just a POC though, you probably need more to avoid infinite

Yeah, I spoke too soon.  I thought I had it working.  The syntax
for doing this is a bit too tortured.

John

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



Re: [users@httpd] configuring a proxy fallback

2018-05-18 Thread Yann Ylavic
On Fri, May 18, 2018 at 11:02 PM, John Bazik  wrote:
>> Doesn't ErrorDocument to a proxied path work? Something like:
>>
>> ProxyErrorOverride on
>> ErrorDocument 404 /internal_404/
>> ProxyPass /internal_404/ http://legacy_site/whatever/
>> ProxyPassReverse /internal_404/ http://legacy_site/whatever/
>
> Wow, thanks!  I assumed that "local url" in the docs meant no.
> That works exactly as I want it to.

OK, was just a POC though, you probably need more to avoid infinite
loops and take care of original requests to "/internal_404/".
Possibly something like this (REDIRECT_STATUS being set on
ErrorDocument handling only):

ProxyErrorOverride on
ErrorDocument 404 /internal_404/
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^/internal_404/ http://legacy-site/whatever/ [P]

Eventually saving the original path somewhere for "whatever" before,
if it matters, with setenvif or another rewriterule.
You get the picture...

Regards,
Yann.

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



Re: [users@httpd] configuring a proxy fallback

2018-05-18 Thread John Bazik
> Doesn't ErrorDocument to a proxied path work? Something like:
> 
> ProxyErrorOverride on
> ErrorDocument 404 /internal_404/
> ProxyPass /internal_404/ http://legacy_site/whatever/
> ProxyPassReverse /internal_404/ http://legacy_site/whatever/

Wow, thanks!  I assumed that "local url" in the docs meant no.
That works exactly as I want it to.

John

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



Re: [users@httpd] configuring a proxy fallback

2018-05-18 Thread John Bazik
> I wonder if, as a workaround, you might use an errordocument that
> converts 404 to 301 or 302, and redirects to $static/$request_uri?

Even if that works, it has to be an internal redirect.

John

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



Re: [users@httpd] configuring a proxy fallback

2018-05-18 Thread Yann Ylavic
On Thu, May 17, 2018 at 5:07 PM, John Bazik  wrote:
>> Oh I see, I didn't realize legacy was also proxied.  Maybe
>> ProxyErrorOverride helps with one of the options?
>
> That lets me use ErrorDocument on the proxy, but it doesn't
> let me redirect the original request to the legacy site.

Doesn't ErrorDocument to a proxied path work? Something like:

ProxyErrorOverride on
ErrorDocument 404 /internal_404/
ProxyPass /internal_404/ http://legacy_site/whatever/
ProxyPassReverse /internal_404/ http://legacy_site/whatever/


Regards,
Yann.

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread Nick Kew

> On 17 May 2018, at 18:44, John Bazik  wrote:
> 
> 
>> Would you be able to share the nginx config to achieve what you're
>> looking for, as a reference point?
> 
> Sure.  Condensing it, the basic idea is this;
> 
>location / {
>uwsgi_pass cms;
>include uwsgi_params;
>uwsgi_intercept_errors on;
>error_page 404 = @fallback;
>}
>location @fallback {
>try_files $uri @static;
>}
>location @static {
>proxy_pass  http://static/$request_uri;
>}

Gotcha.  Interesting that that works: it kind-of implies the possibility
of recursive error documents.

I wonder if, as a workaround, you might use an errordocument that
converts 404 to 301 or 302, and redirects to $static/$request_uri?

(apologies if this is the beer speaking: just back from an evening out).

-- 
Nick Kew

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread John Bazik
> A bit of an ugly hack (and probably not useful), but what about an
> errordocument that uses SSI to include your contents?

Mmm.  I don't want to go there.

> Would you be able to share the nginx config to achieve what you're
> looking for, as a reference point?

Sure.  Condensing it, the basic idea is this;

location / {
uwsgi_pass cms;
include uwsgi_params;
uwsgi_intercept_errors on;
error_page 404 = @fallback;
}
location @fallback {
try_files $uri @static;
}
location @static {
proxy_pass  http://static/$request_uri;
}

John

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread Nick Kew

> On 17 May 2018, at 16:07, John Bazik  wrote:
> 
>> Oh I see, I didn't realize legacy was also proxied.  Maybe
>> ProxyErrorOverride helps with one of the options?
> 
> That lets me use ErrorDocument on the proxy, but it doesn't
> let me redirect the original request to the legacy site.

A bit of an ugly hack (and probably not useful), but what about an
errordocument that uses SSI to include your contents?

Would you be able to share the nginx config to achieve what you're
looking for, as a reference point?

-- 
Nick Kew

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread John Bazik
> Oh I see, I didn't realize legacy was also proxied.  Maybe
> ProxyErrorOverride helps with one of the options?

That lets me use ErrorDocument on the proxy, but it doesn't
let me redirect the original request to the legacy site.

John

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread Eric Covener
On Thu, May 17, 2018 at 10:51 AM, John Bazik  wrote:
>> FallBackResource may be one option. Another might be the "lookahead"
>> feature in mod_rewrite. Another is to poke and prod with -d/-f tests
>> in mod_rewrite if you can determine that way.
>
> All of those respond to a missing file, not a 404 returned from a
> proxied request.  That's where I keep hitting a wall.
>
Oh I see, I didn't realize legacy was also proxied.  Maybe
ProxyErrorOverride helps with one of the options?

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread John Bazik
> FallBackResource may be one option. Another might be the "lookahead"
> feature in mod_rewrite. Another is to poke and prod with -d/-f tests
> in mod_rewrite if you can determine that way.

All of those respond to a missing file, not a 404 returned from a
proxied request.  That's where I keep hitting a wall.

John

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



Re: [users@httpd] configuring a proxy fallback

2018-05-17 Thread Eric Covener
On Thu, May 17, 2018 at 10:42 AM, John Bazik  wrote:
> Here's something I think I can't do with apache.
>
> I have a uwsgi backend server and a legacy http server.  I would like a
> reverse proxy that puts the dynamic site "in front of" the legacy site,
> such that 404s from the former are internally redirected to the latter.
>
> We have this implemented in nginx, but I recently needed to switch the
> proxy to apache.  ErrorDocument is the obvious hook, but it has to be
> a local url.  I've looked at the rewrite engine and balancer groups,
> and I haven't found any way to do this.  I was about ready to give up
> and thought I'd see if smarter people than me have an answer.
>

FallBackResource may be one option. Another might be the "lookahead"
feature in mod_rewrite. Another is to poke and prod with -d/-f tests
in mod_rewrite if you can determine that way.

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