Pregunta

I have 2 servers, we can call them A and B. Server A has a website facing to public, it has proper domain name and everyone is able to access it via Internet. Server B is in the same network as Server A. Server B has a internal website running with domain name: http://b.domain.local/

So, Server A can access Server B's website content, all pages, img, etc...

In Server B's website, there are few dynamic scripted images link, for example link: http://b.domain.local/img.php?Action=view&ID=5 This will only return a image, and it will display a status of some figures.

I need to put this image in one of the web page on Server A to display it to public.

Is that possible? And how I can do this? I think this is similar to some web based proxy site: Client -> request to Server A, Server A -> request to Server B, Server B returns value back to Server A, Server A returns result to Client... Isn't it?

I'm using C# MVC4 on Server A.

Thanks

River

¿Fue útil?

Solución

I'm guessing you are using IIS on server A? Could you share a folder that contains the image on server B and setup a virtual directory in IIS on server A that points to the share on server B. So you can still keep it on server B, but serve it publicly on server A. Of course, this is assuming you have an actual image file to share.

Or, there is the option you said about a proxy page that could get the image too. I've done this on a site before and it does work, but there is more overhead in doing that. If the image is dynamically generated from the link you provided for server B, then this will be the only option as the public won't have direct access to it.

I would achieve a proxy style page with the following code:

Response.ContentType = "image/jpeg";
HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream stream = httpWebReponse.GetResponseStream();
Image _Image = Image.FromStream(stream);
_Image.Save(Response.OutputStream, ImageFormat.Jpeg);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top