Hi! It's a simple question, I'm new in this subject.
How can I get all the subrequests from a proxied server to go through my proxy? Not only the doc root, but all the assets (images, js, css, etc) (considering they are at the same server).
What I did was this, which works, but it should it is bad code.
location / {
proxy_set_header Accept-Encoding "";
sub_filter_types *;
sub_filter_once off;
sub_filter "http://myorigin.com" "https://myproxy";
proxy_pass http://myorigin.com;
}
I'm trying to use ngx.location.capture with no success. Something like this:
location / {
try_files $request_uri @proxy_test;
}
location @proxy_test {
content_by_lua_block{
res = ngx.location.capture('/backend', {method = ngx.HTTP_GET, always_forward_body = true, copy_all_vars = true})
}
}
location /backend {
internal;
proxy_pass http://myorigin.com$request_uri;
proxy_redirect off;
}
Thanks in advance. Any tips will be appreciated.