How to preserve the Client IP and pass it through ESP in Google Cloud Endpoints ESP Proxy? - google-cloud-endpoints

I have an application as an API using Google Cloud Endpoints which uses ESP as a proxy, my API application uses a service of type LoadBalancer. The App and the ESP proxy run inside the same pod, what I want is to preserve the client IP when they hit the ESP first and forward it to the API appliaction, I used the custom nginx config file here; https://cloud.google.com/endpoints/docs/openapi/custom-nginx and the forwarding didn't work, the application access log keeps showing remote address as 127.0.0.1:55922 which is the ESP proxy's ip not the remote client.
So what modification or config should I make to force ESP to forward the Clients IPs?

Related

Is there somebody who knows how to send data from a webhosted webdomain to a ESP32 using http get request?

The question is, how can we send data from the Webhosting domain to our esp32 with an HTTP GET Request?
If the ESP32 is behind a local network this is not possible.
If you want to initiate a request from outside of the network where the ESP32 is, you must put the esp32 to the internet.
You can port forward the ESP32's ip address/port on your router. That way you can reach the esp32 via your router's public ip. That way you can do any HTTP request to the ESP32 from anywhere in the world.
I warn you however that this method is not recommended since your network will be open to the outside world on the port you opened.
An other way is to use some kind of a tunnel server.
There are solutions for that such as ngrok or husarnet
I would recommend you to create a server somewhere in the cloud and fetch the desired data from that server with the esp32. Since you can request data inside your local network from the outside.

How to port forward external IP to websocket server hosted locally?

I have created a local websocket server using the ktor framework, which is available locally in the below IP.
[main] INFO Application - Responding at http://192.168.1.10:8080
And I'm able to access it locally from postman by hitting
ws://192.168.1.10:8080/chat
I would like to connect to this socket from the internet, But when I setup port forwarding (using NAT virtual server configuration), this doesn't seem to work. I get timed out error.
I tried this because, it is working fine for the http server (express app) I created in another port. From the below NAT virtual server configuration, I was able to do port forwarding and access the webservice from the internet.
I'm quite new to socket programming and networking. Kindly advice.
You can't have a single External Port mapped to two different Server ports. Each Server needs a distinct External Port mapped to it. Right now, you have External Port 80 mapped to both 192.168.1.10:3000 and 192.168.1.10:8080.
Once you fix that issue to use a separate External Port for each Server, then http://<externalIP>:<externalPort1> and ws://<externalIP>:<externalPort2> should work properly to reach the HTTP and WebSocket servers, respectively, from the outside world.

How to get IP of incoming requests while using ngrok?

I am using ngrok to tunnel 8000 port, on which my django project is running. ngrok prints all incoming requests on the console, I want it to print the IP address of source of incoming requests as well.
You can see verbose information about each and every request on ngrok's web interface at http://127.0.0.1:4040
It's not as conventient as having it on the CLI directly but it's a way.

Pivotal cloud foundry - Application listening on TCP port

I am trying to run an test app on pivotal cloud foundry, that listens on TCP port 2222. I was able to create a TCP route however i was not able to reach this server from a client outside, any ideas? on the same vm i am able to connect.
You need to talk to your platform operator. In addition to mapping a TCP route to your app, you need to have load balancers configured to route TCP traffic into the platform.
Please check with your platform operator to see if the following steps have been performed.
https://docs.pivotal.io/pivotalcf/2-3/adminguide/enabling-tcp-routing.html

Routing external calls to api with out a domain name

I have a client that does api calls to a owin server. When calling e.g. http://192.168.345.13:8000/api/status it works fine when doing this from a local machine on the same LAN as the server.
When using the same aurelia client from a remote machine e.g. a 4g smartphone then the client code is shown but the api calls don't work. My router forwards the port to the server machine so external ip a.b.c.d:8000 routes to the server.
This is ofcourse because the client has hardcode : http://192.168.345.13:8000/api/status.
My question is how do i support both local and remote via the same API? Can i detect this in the client code?
Can i detect a remote ip and switch to external ip (a.b.c.d:8000/api/status)?
Any sugestions are welcome!
Turns out that had some old ip filtering on. After disabeling this it works now. Using the external ip for the server the server ip calls.
When on the local network i use the local machine ip in the browser and when accesing from e.g. 4g Phone then i use the external ip.

Resources