0
votes

I have a confusion and problem with doing maybe strange thing. I've got application, where we send a request at http://somehost:9000/endpoint/x. In /etc/hosts where is our app running we've got 123.123.123.123:somehost mapping. But on our production environment we can't touch hosts file. So we've got create proxy on nginx. So.. Is it possible to request into nginx (http://nginx:80/endpoint/x) for example and he will do that hosts mapping inside? Additional things is that we have to add .p12 certificate (it can be copied straight to nginx directories) and body + HTTP headers from request which we send from application. I think that part with hosts mapping is mostly confusing me - I don't know how to make it.

server {
    listen              80;

    location / {
        proxy_pass http://somehost:9000;

    }
}

It is a idea about sample proxy, but how to make this host mapping from that given host? Thanks!

1
Do you want to specify the IP address of the service in the Nginx configuration file? - Richard Smith
Hm, what do you mean? Problem is that I can't send request directly to 123.123.123.123, I have to request it by somehost and map DNS in hosts file 123.123.123.123:somehost - saculo

1 Answers

0
votes

You cant' use /etc/hosts on server but you could use nginx upstream module. Like this

upstream somehost {
  server 123.123.123.123:9000;
}

server {
    ...
    location / {
        proxy_pass http://somehost;

    }
}