1

i have this NGINX location in my default.conf

   location /api-gateway/ {
       proxy_http_version 1.1;
       proxy_connect_timeout 75s;
       proxy_read_timeout 100s;
       client_max_body_size 100m;
       proxy_set_header Host test.domain.com;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Host $host;
       proxy_set_header X-Forwarded-Port $server_port;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_buffering off;
       proxy_buffers 16 8k;
       proxy_buffer_size 4k;
       proxy_max_temp_file_size 0;
       rewrite ^/api-gateway/(.*)$ $1 break;
       proxy_pass http://ingress-srv; # ingress-srv is an upstream
    }

here is an example of the request that is coming to my NGINX server: http://demo.domain.com/api-gateway/service/v1/metrics

i need to do the below

  • remove the /api-gateway/ from the original url and then,
  • rewrite/send the requests to ingress-srv upstream without changing the URL (no redirect)
  • change the header from demo.domain.com to test.domain.com which i believe i have done it correctly

i can not make it work ..

1 Answer 1

5

Instead of

proxy_pass http://ingress-srv; # ingress-srv is an upstream

try doing (notice the slash):

proxy_pass http://ingress-srv/; # ingress-srv is an upstream

You can take out the rewrite directive.

As Oscar Wilde said "I was working on nginx.conf all the morning, and took out a comma. In the afternoon I put it back again."

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.