Determine IP Address outgoing request comes from - asp.net-mvc

If I have a link in an MVC application hosted on Azure:
Call web service
At the moment we are having difficulty connecting to the URL, which is a SOAP web service. We get an error 'site cannot be reached'.
Just to rule something out - what IP address would the service see this request coming from - my local (browser) or the server?

The request would come from your IP.

Related

Application Gateway with Web App Backend (domain not resolving)

I have a both a multi and single site Application Gateway with a Web App backend pool. Settings at the backend pool point to port 80 (http).
I am using a personal domain of example: www.mydomain.club and using either web host or DNS. When I enter www.mydomain.club into the browser, it resolves to https://mywebapp.azurewebsites.net:80 in the browser bar, with error message on page indicating that I cannot reach the site.
It seems like the DNS/host recognizes the domain resolving required, but tries push for port 443 (https), but indicates there is a port 80, while returning the web app address (even though I'm going through the application gate). If I restrict access the web app, I get a 401 error.
I have tried:
CNAME pointing to the DNS name for Application Gateway IP - mydns.eastus.cloudapp.azure.com
A recording using both # and WWW pointing to the Gateway IP.
Overriding the host name in the backend settings.
• As seen from the URL, i.e., ‘https://mywebapp.azurewebsites.net:80’, the Azure webapp website points to ‘HTTPS’ port 443 but you might have configured the webapp’s website incorrectly in the backend pool for ‘HTTP’ port 80. Due to which when you are trying to access the ‘www.mydomain.club’ domain name over the internet, it is redirecting you to the ‘https://mywebapp.azurewebsites.net:80’ URL as you have configured it so in the application gateway’s backend pool.
Thus, would suggest you to please reconfigure the ‘https://mywebapp.azurewebsites.net:80’ to only ‘https://mywebapp.azurewebsites.net’ in the application gateway’s backend pool. This will ensure that the website ‘www.mydomain.club’ is redirected correctly to the above said website only and the pages hosted in that webapp will be displayed correctly.
• Secondly, please do ensure that you have created an ‘A’ host record for ‘www’ in the public DNS zone for ‘mydomain.club’ domain which will ensure that the website is hosted on a publicly available IP address and domain name. Also, since you want the website domain name, i.e., ‘www.mydomain.club’ to be redirected to the application gateway URI/FQDN, i.e., ‘xyz.eastus.cloudapp.net’, then create a CNAME record for ‘www.mydomain.club’ address with the alias as ‘xyz.eastus.cloudapp.net’. This will ensure that when trying to access the domain name ‘www.mydomain.club’, it will be redirected to the application gateway’s URL and will be displaying the backend site web page accordingly as defined in the routing rules and the listener rules.
This will ensure that, you will not encounter 401 error when accessing the website DNS, i.e., ‘www.mydomain.club’ and it opens correctly.
Please find the below documentation link for more details: -
https://learn.microsoft.com/en-us/answers/questions/379193/application-gateway-with-a-custom-domain-name.html

Can I use my own device as redirect URI with OAuth2

I'm building an application in a device (Point of Sale) and for this I need to use OAuth servers to authenticate a webservice request, the guys on the side of the webservice are now asking me for a redirect URI, I do not have any experience on this so I started googling around 'redirect URI's, so now I wonder, given that this app works on a device (not on cloud), is there a way I can use my own device as the redirect URI and catch the webservice response there (such as the JSON)?
Extra info it might work (or not): In my office we all use DHCP but we have a configurable server.
Thank you.
It is possible to redirect to your own device if it is running its own web server.
This is because the redirect URI is passed back to the requesting client's browser which performs the redirect as shown in the diagram below from this tutorial. From there the browser can redirect to a local device's web server using the following approaches:
Use localhost or the 127.0.0.1 loopback IP for the redirect URI. This will work in the client's browser but not all services may allow registering a redirect URL to localhost or 127.0.0.1.
Use an external host which is mapped to the local system. On a Linux system, this can be configured by placing the hostname the /etc/hosts file and pointing it to the local system loopback IP address, e.g. 127.0.0.1. This can point to a real server on the Internet which is just redirected on the local system so this approach can be used with any service.
An example /etc/hosts file can contain a hostname like example.com which is then used in the redirect URI.
127.0.0.1 localhost example.com
Read more about localhost and the loopback IP address on Wikipedia:
https://en.wikipedia.org/wiki/Localhost
Diagram courtesy of TutorialsPoint.com.

Creating a websocket with ngrok

I am using ngrok to tunnel to my ASP.NET core application. I am using Fleck to try and create a websocket connection between my application (server side) and an external API (client side). The problem is, the API requires a URL (ws://mysite.com/socket) that it will request a websocket connection from, however, the WebSocketServer(ip) object creates a websocket on a certain IP address and port. Can I tell the API to try and establish a connection with ws://5f1ce6fe.ngrok.io? Also, how do I find the IP address/port combination using ngrok that I will use to open the appropriate websocket on my server so that it accepts a websocket request at ws://5f1ce6fe.ngrok.io?
Thanks

get Client public Ip address in web api

i am using an service to get client country based on the ip address but it is made through web api rest service when i used UserHostAddress it shows internal ip only when i send this to service it is showing wrong country is there any solution to get country or ipaddresss
If you have local ip, and your router has the real one, your computer only communicates with router, and router communicates with Internet. There are two ways of getting routers IP:
Send http request to some site that shows your IP and get it from there.
Connect to router interface and get IP directly from router.

Check Page Request Source

Working on a data collection application using mobile sms.
when a customer send a sms lets say
SMS content
Demo CET 100-50030-2320-1000
when the sms reach the mobile serive provider it send a GET request on my server
http://domainname.com/demo.aspx?mno=9828958745&sms=CET+100-50030-2320-1000
Now the problem is some hackers are sending GET request from there PC browser and all the data is getting missed and server is getting overload
I want to know which request is from a computer(mobile server) and which are from browser.
thanks in advance
Regards
Check if the request for a page is coming from a server not a browser.
If your service is not meant to be accessible publicly you have to protect it instead of publishing it on the internet. Some wasy to protect it:
HTTP Authentication
IP restrictions in firewall.
IP restrictions in the service.
Virtual Private Network.

Resources