By Alan

2017-10-29 10:24:24 8 Comments

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

Example: If I have to connect to through a Linux server box, I have to set proxy as and only then I can connect to

So how can I achieve it in nginx config?

My Nginx config file sample goes like this:

       listen     80;
       server_name   *;
      return 301     https://$host$request_uri;
    location / {
      sendfile            on;
      try_files           $uri $uri/ /index.html
    location /xyz{

Here, I need to pass my proxy in the Nginx config itself and only then I can connect to

So basically, every request from my server box should pass via to the proxy_pass location mentioned in nginx config.

I tried mapping the http host and served host and passing it in the location but it is not working:

map $http_host $served_host {
        default $http_host;;

location /xyz{
         proxy_set_header Host $served_host;


Related Questions

Sponsored Content

8 Answered Questions

[SOLVED] How to preserve request url with nginx proxy_pass

2 Answered Questions

Keycloak Redirect url with nginx is going to http rather than https

  • 2018-04-03 12:02:15
  • Atulya Nair
  • 1097 View
  • 3 Score
  • 2 Answer
  • Tags:   nginx jboss

2 Answered Questions

[SOLVED] Express - req.ip returns

0 Answered Questions

How to write NGINX config file to use ReactJS? (on Docker)

  • 2018-09-30 18:01:56
  • Wilson López Romero
  • 65 View
  • 0 Score
  • 0 Answer
  • Tags:   reactjs docker nginx

0 Answered Questions

Nginx as a forward proxy

0 Answered Questions

Passing a proxy URL before using proxy pass in Nginx config

1 Answered Questions

Nginx win server 2012 - Configure proxy pass

  • 2017-07-31 15:02:09
  • johns193
  • 276 View
  • 0 Score
  • 1 Answer
  • Tags:   nginx proxy

2 Answered Questions

How to point many paths to proxy server in nginx

0 Answered Questions

2 Answered Questions

[SOLVED] nginx and trailing slash with proxy pass

Sponsored Content