dimanche 11 août 2019

How to pass request uri to error page location in nginx?

I have two locations with error page directive:

server_name               ~^w?w?w?\.?(?<submodule>.*)\.(?<module>.*)\.project\.com$ ;
location = / {
  proxy_intercept_errors  on;
  proxy_pass            https://storage.googleapis.com/project/$module/$submodule/index.html;
  error_page              404 = @default;
}

location / {
  proxy_set_header        Host storage.googleapis.com;
  proxy_pass              https://gs/project/$module/$submodule$request_uri;
  proxy_http_version      1.1;
  proxy_redirect          off;
  proxy_intercept_errors  on;
  error_page              404 = @default;
}
location @default {
  proxy_set_header        Host storage.googleapis.com;
  proxy_pass              https://gs/project/$module/default$request_uri;
  proxy_redirect          off;
}

I would like nginx error_page to perform internal redirect such as all failing requests to /project/$module/$submodule$request_uri are redirected to /project/$module/default$request_uri.

Currently I am getting an error, due to missing request_uri in @default location:

<Error>
  <Code>NoSuchKey</Code>
    <Message>The specified key does not exist.</Message>
  <Details>No such object: project/module/default</Details>
</Error>




Aucun commentaire:

Enregistrer un commentaire