Skip to content

Allow custom variables in action.return body #8255

@defanator

Description

@defanator

Is your feature request related to a problem? Please describe.

We are trying to construct a specific route for extended health check which would return a combination of custom variables created via map, but for some reason existing implementation allows very limited subset of nginx variables to be included into action.return's body:

https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#actionreturn

Describe the solution you'd like

Remove any sanity checks for action.return body to make it in line with the return directive does in nginx and (ideally) avoid extra proxy_pass step as well. Currently what could be done in a single location like this:

location /my_return {
    return 200 "hey, myvar";
}

expands into this:

    location =/whoami {
        set $service "";
        status_zone "";

        error_page 418 =200 "@return_1";
        proxy_intercept_errors on;
        proxy_pass http://unix:/var/lib/nginx/nginx-418-server.sock;
        set $default_connection_header close;
    }

    location @return_1 {
        default_type "text/plain";
        
        # status code is ignored here, using 0
        return 0 "hey, myvar
";
    }

What's the point of extra proxy_pass step?

Describe alternatives you've considered

Using one of existing upstreams/svcs and action.proxy with location snippets. That works, but generates lots of dead code (config which would never execute), and affects the status_zone of a given svc (e.g. all health check requests are being counted as that svc requests which is not acceptable).

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlog candidatePull requests/issues that are candidates to be backlog itemsproposalAn issue that proposes a feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions