0

I'm facing a challenge and need some help, please.emphasized text

It's quite simple, I need to set a custom header as a response from an http request to an internal app I have running on the same instance.

I have two applications running on docker in one instance.

I need to set a custom header on the APP 1 and the value of this header is an api call to APP 2.

NGINX config APP 1:

server {
    server_name example.com;
    location / {
        proxy_pass http://localhost:6987;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        proxy_set_header user-code 0.0.0.0:6500?code=$geoip2Lite_data_city_name;
    }

APP 2 it's a simple app that has an end-point that returns a value accordingly to the code query parameter. This app is running on docker on the same instance.

What I'm looking for, is that all requests that comes to APP 1 have the header user-code with the actual response of the Api call.

Example:

If a user access my app from Lisbon an GET request to http://0.0.0.0:9982?code=Lisbon will be made the response of of this request is 236578552 thus the header user-code will be 236578552

Is that possible to be done in NGINX?

Thank you all in advance, Cheers!

0 Answers0