http-server-redirect #
The ngx_http_server_redirect_module is a custom nginx module designed to facilitate dynamic server redirection based on configurable rules. It allows users to redirect incoming requests to different servers conditionally.
Source: upstream source
Directives
schedule_redirect #
syntax: schedule_redirect on | off (on/off flag); · context: server
Here is an example: This example redirects requests to newserver.com if the Server-Redirect header has value and value is not 0. ### Directive: schedule_redirect Syntax: schedule_redirect on | off Default: schedule_redirect off Context: server Redirect the current request to another server from the first request path.
Example
http {
server {
listen 80;
server_name example.com;
# Enable schedule redirection.
schedule_redirect on;
# Requests will not arrive here unless the first path in the request path does not exist or the host in the first path is invalid.
return 400 "request path invalid";
}
server {
listen 80;
server_name newserver.com;
# You can get original host from this variable.
add_header x-original-host $server_redirect_original_host;
location / {
proxy_pass http://upstream.com;
}
}
}