Passing a proxy URL before using proxy pass in Ngi

2019-03-03 19:43发布

I need to pass a proxy URL to connect to other URLs mentioned as proxy pass in Nginx.

Example: If I have to connect to google.com through a Linux server box, I have to set proxy as xyz.org:80 and only then I can connect to google.com.

So how can I achieve it in Nginx config?

My Nginx config file goes like this:

http {
include mime.types;
}
server{
   listen     80;
   server_name   *;
  return 301     https://$host$request_uri;
}

location /xyz{
   proxy_pass     google.com/
}

Here, I need to pass my proxy xyz.org:80 in the nginx config itself and only then I can connect to google.com/.

So basically, every request from my server box should pass via xyz.org:80 to the proxy_pass location.

0条回答
登录 后发表回答