I am trying to write client side code to hit a rest service on another internal server that contains no public ip address. Because of this I am trying to write a small web service to take the id it needs and hit the rest service from the web server.
I have created a web service as shown below to hit the rest service from the web server and while I have success, the client side
<System.Web.Services.Webmethod()> _
Public Shared Function GetService(ByVal id as Integer) as String
dim serviceUrl as string = "http://192.168.0.87/rest/services/"
dim httpWebRequest as System.Net.HttpWebRequest = System.Net.WebRequest.Create(serviceUrl)
httpWebRequest.ContentType = "text/json"
httpWebRequest.Method = "GET"
dim httpResponse as System.Net.HttpWebResponse = httpWebRequest.GetResponse()
Using streamReader as new System.IO.StreamReader(httpResponse.GetResponseStream())
Return streamReader.ReadToEnd()
End Using
End Function
While this works correctly for one call, that same call's results then references URL's for further service calls eg fetching images etc.
Is there any .Net applications out there, or any solutions out there to write a service with the external ip address and a specific path and automatically redirect the address server side into the internal ip address's rest call.
eg if a client hit 203.141.86.2/rest/services
it would automatically translate into the internal ip address of 192.168.082/rest/services
via a middle man service.
eg the 203.141.86.2/rest/services would actually be a real address that would just translate everything after it and put it into the new address. Note: The existing solution is written in web forms and not in MVC, so I am unsure if a new single IIS application needs to be set up to handle these call translations as a webapi.
It is basically being like NAT service.
Does anyone have any solutions? Thanks in advance.
What you are trying to achieve is called reverse-proxy. Try nginx. http://nginx.org
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.