http – How to forward the contents of a login-protected site via the web?

Since I am a new user, first of all I would like to thank the whole StackExchange community. Many times I have found a solution here for my questions. But now, time has come for my first post.

It’s entirely possible that the answer can be found here somewhere, but since I cannot really figure out which keywords to search for, I am seeking for help.

I administer website A that provides information for a number of users. Website B is an external website containing information that I would like to provide to the users of site A. Login credentials via basic HTTP authentication are required to access B. As the users of A do not know these login credentials, I am searching for a way to have the server of A (which I have full access to) acting like some sort of proxy between the users of site A and site B itself.

Here’s how I imagine the sequence of actions:

  1. User X clicks a link on A, a new browser window (or tab) opens
  2. Server A logs in to B
  3. B is mirrored to the new tab on X’s browser
  4. X is now seeing B as if he had logged in himself
  5. When X clicks a link on B, the HTTP request is not directly handled by B, instead A forwards the request to B and B’s reply to X

The main goal is to enable the users to access B without having to know the login credentials.
A nice extra would be if B would only see A’s IP, not the user’s IP.

Because information on B changes frequently, using a method similar to creating a snapshot of B that is hosted on A won’t work even if that snapshot is created in regular intervals.

I am looking forward to your ideas. Many thanks in advance!