Home>Article>Operation and Maintenance> How to pass parameters in nginx reverse proxy

How to pass parameters in nginx reverse proxy

(*-*)浩
(*-*)浩 Original
2019-11-01 11:21:12 21167browse

The reverse proxy service of Nginx server is its most commonly used important function. The reverse proxy service can also derive many important functions of Nginx server related to this, such as load balancing which will be introduced later. .

How to pass parameters in nginx reverse proxy

Reverse proxy, in fact, the client is unaware of the proxy, because the client does not need any configuration to access, we only need to send the request to the reverse proxy Server, the reverse proxy server selects the target server to obtain the data, and then returns it to the client. At this time, the reverse proxy server and the target server are one server to the outside world. The proxy server address is exposed and the real server IP address is hidden. (Recommended learning:nginx tutorial)

nginx reverse proxy configuration:

location ~ \/someuri { access_log /var/log/nginx/uploads.log; proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_read_timeout 300; proxy_pass $scheme://proxy_location$uri; recursive_error_pages on; }

As shown in the above code, reverse proxy can be performed. But there will be problems with this:

If request parameters are added to the url, the request parameters will not be included after forwarding using $scheme://proxy_location$uri, so the $uri variable cannot be used. If necessary If you continue to carry request parameters,you need to use $request_uri, that is, proxy_pass $scheme://proxy_location$request_uri;

The above is the detailed content of How to pass parameters in nginx reverse proxy. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn