Nginx - Proxy

Nginx - Proxy

About

proxy in Nginx

Example

A proxy is defined in a location block

upstream targetService {
    server 127.0.0.1:8080;
    # A keepalive directive sets the maximum number of upstream idle connections that can remain open at any given time (for each Nginx worker process).
    keepalive 64;
}

location / {

	proxy_set_header X-Forwarded-Host $host;
	proxy_set_header X-Forwarded-Server $host;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-Proto "https";
	proxy_pass http://targetService;
	proxy_http_version 1.1;
	proxy_pass_request_headers on;
	proxy_set_header Connection "keep-alive";
	proxy_store off;

}

where:

Proxy Pass

If the URI is specified along with the address, it replaces the part of the request URI that matches the location parameter.

For example, with the below configuration:

location /some/path/ {
    proxy_pass http://www.example.com/link/; # the end slash is important
}





Discover More
Nginx - Location block

A location block is a block that is located inside a server block and maps a a resource path to a destination path such as: a local directory or an other service (see ) A server block may have several...
What is an HTTP Proxy?

An HTTP proxy is a proxy that re-routes the HTTP message (request and response). It sits between the client and the origin server. There is two kinds of proxy but they are just the same application,...



Share this page:
Follow us:
Task Runner