from http://wntest.ustc.edu.cn/mine/wordpress/?p=400and http://hi.baidu.com/171892549/blog/item/0ec6aaef22acbb1dfdfa3ca7.html
Nginx's Proxy_redirect feature is powerful, and its role is to modify the URL that is sent to the client. Take an example to illustrate:
server {
Listen 80;
server_name test.abc.com;
Location/{
Proxy_pass http://10.10.10.1:9080;
}
This configuration is generally normal, but occasionally error, where is the error? The Catch Packet Discovery server added a port number to the client's jump command, such as location:http://test.abc.com:9080/abc.html. Because the Nginx server is listening on port 80, so the URL to the client, it will inevitably error. In this case, add a proxy_redirect directive: Proxy_redirect http://test.abc.com:9080//, put all The "http://test.abc.com:9080/" content is replaced with "/" and then sent to the client, it is resolved.
Proxy_redirect
Syntax: Proxy_redirect [Default|off|redirect replacement]
Default value: Proxy_redirect default
Using fields: HTTP, server, location
You can set this command if you need to modify the "location" and "Refresh" fields in the answer header that came from the proxy server.
Assume that the proxy server returns the Location field: http://localhost:8000/two/some/uri/
This command:
Proxy_redirect http://localhost:8000/two/http://frontend/one/;
Rewrite the location field to http://frontend/one/some/uri/.
The server name may not be written in the replaced field:
Proxy_redirect http://localhost:8000/two//;
This uses the base name and port of the server, even if it comes from a non-80 port.
If the "default" parameter is used, it is determined based on the settings of the location and Proxy_pass parameters.
For example, the following two configurations are equivalent:
location/one/{Proxy_pass http://upstream:port/two/; Proxy_redirect default;} location/one/{Proxy_pass http://upstream:port/two/; Proxy_redirect http://upstream:port/two//one/;}
Some variables can be used in directives:
Proxy_redirect http://localhost:8000/http://$host: $server _port/;
This instruction can sometimes be repeated:
Proxy_redirect default; Proxy_redirect http://localhost:8000//; Proxy_redirect http://www.example.com//;
The off parameter disables all Proxy_redirect directives in this field:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.