remoteAddr in Cloudfoundry - cloud-foundry

I developed a grails app that recognizes the visitors country by using request.remoteAddr. I pushed the app to cloudfoundry and it works well but all the values for remoteAddr are all internal for cloudfoundry like 172.30.49.25 so my app doesn't recognize any country. I tried this address in http://www.ip2location.com/demo - same result.
So the question is: how can I get the actual IP address of the user in the Grails or Java application deployed in CloudFoudry?

You should be able to get this data from the X-Cluster-Client-IP or X-Forwarded-For HTTP request headers.
Something like:
request.getHeader("X-Cluster-Client-IP")

Related

Can a remote server send response to a local client on a custom port?

For network gurus out there, I'll like to ask some questions regarding some unique setup where the server will be sending a request to a client on localhost on a certain port.
I have a cloudy understanding of some network fundamentals that I hope you'll be able to help me out.
Kindly check the image below:
Basically, there's a static website hosted in AWS s3 and at some point this website will send a request to https://localhost:8001.
I was expecting that it will connect to the nginx container listening on port 8001 in my local machine, but it results in 504 gateway error.
My questions are:
Is it possible for a remote server to directly send data to a client at a particular port by addressing it as localhost?
How is it possible for the static website to communicate to my local docker container?
Thanks in advance.
In the setup you show, in the context of a Web site, localhost isn't in your picture at all. It's the desktop machine running the end user's Web browser.
More generally, you show several boxes in your diagram – "local machine", "Docker VM", "individual container", "server in Amazon's data center" – and within each of these boxes, if they make an outbound request to localhost, it reaches back to itself.
You have two basic options here:
(1) Set up a separate (Route 53) DNS name for your back-end service, and use that https://backend.example.com/... host name in your front-end application.
(2) Set up an HTTP reverse proxy that forwards /, /assets, ... to S3, and /api to the back-end service. In your front-end application use only the HTTP path with no host name at all.
The second option is more work to set up, but once you've set it up, it's much easier to develop code for. Webpack has a similar "proxy the backend" option for day-to-day development. This setup means the front-end application itself doesn't care where it's running, and you don't need to rebuild the application if the URL changes (or an individual developer needs to run it on their local system).

Do we have to host our Django site for our Flutter App backend?

Suppose I am creating a todo list app in Flutter. I have used Django to connect flutter's backend with the local host database. Now my API's(Django Rest Framework) are working fine if the is on local machine. But what if I deploy my Flutter app to Play Store? Then I need to host my Django site as well or it can be upon the local machine?
Development
If you are in development the local machine is enough. For connecting the Flutter app to the Django development server follow the steps below.
connect your local server and mobile device to the same network (for example, a common wi-fi)
Get the IP address of the local machine. In Linux, the command is ifconfig,
and in Windows, it is ipconfig. It will be something like 192.168.1.8
Run the Django server with the following command in the terminal, providing your IP address you got in step 2:
python manage.py runserver 192.168.1.8:8000
To test, try access the IP address (with port) via. a browser on the phone. If it loads, the connection is correctly set up
Now you can use this address in your request in the HTTP request in Flutter
Production
If you are deploying the app in production, you can host a server (AWS/EC2, for example). You will get the IP address somewhere in the console. Deploy the code to the server and run the code there. Replace the local IP address in app with the IP address of the server. You can also use packages like Environ for this.

How to configure SOAP endpoint on my PC

I'm new at using SoapUI, I'd like to know if my machine supports SOAP and in case yes, what I can use as an endpoint for my newly created SoapUI project.
My machine is a Windows-10, and on top of that I have installed Cygwin (enabling some UNIX features).
Does somebody know how I can retrieve a possible value for an endpoint for my SoapUI project?
Oops, from the comment I have the impression that my question is badly formulated: on my PC I have a server application, of which I don't know if it supports SOAP (I know it supports HTTP because I'm using localhost in a browser to access it).
However when I use localhost or 127.0.0.1 as an endpoint in my SoapUI project, nothing happens (I see no response and the request log stays empty), hence my question.
Per default, mostly no application will act as a SOAP prodiver, as it is much more complicated as REST/http for example.
If your application has the capability of a SOAP provider, it is usually SOAP over HTTP. But you need to know the correct endpoint url address.
Not only 127.0.0.1
Usually there is a servicename in the url (and you can also try to show wsdl with ?wsdl), like http://127.0.0.1/myapplication/myservice?wsdl
when setting up a new soapui project, you also have to provide the wsdl location
(http://127.0.0.1/myapplication/myservice?wsdl)
Regards, rka

Unable to load wsdl file from android browser

I Develop a webservice from a java class using JDeveloper.and deploy it on my local weblogic server. i can access the wsdl directly from my browser . but when i try to access it from my android phone web browser it is not loading it.however i can connect to my local weblogic server via phone. here is the url of mywsdl
http://xxx.xxx.x.xxx:7101/WebServices-Services-context-root/BooksPort?WSDL
Error Message
You tried to access the address which is currently unavailable.make sure that the web address is correctly spelt and punctuated then try reloading again.
Is 7101 is the right port for you wsdl?
Try 7001 and let me know
Are other sites like google.com opening up on your mobile browser? You may require proxy settings to access the WSDL.

Two application servers on one web server?

I have a Rails app which provides service through Nginx server(with thin). Now I want to build another app in Node.js on the same machine.
My question is, can I have Nginx redirect users' reqeusts? e.g. when a user access 'foo.mydomain.com' it will be processed by Rails app, and when she visit 'bar.mydomain.com' it can be processed by Node app.
(I'm not sure whether it's related to the type of apps, i.e. Rails, Nodejs, etc)
You can set up two serverblocks in your nginx config; One listening for bar.mydomain.com and the other one for foo.mydomain.com and then use the proxy_pass module in nginx to pass forward the requests to your Node or Rails app.