How do I write a simple PHP transparent proxy?
curl, libcurl, php, proxy
Solution
What you are talking about is accessing pages for which you need to authenticate yourself.
Here are a few things that must be laid down:
- you can't view those pages without authenticating yourself.
- if the website (whose HTML code you want to see) only supports web login as an authentication method, you will need to simulate login by sending a (username,password) via POST/GET, as the case may be
- if the website will let you authenticate yourself in other ways (like LDAP, Kerberos etc), then you should do that
The key point is that you cannot gain access without authenticating yourself first.
As for language, it is pretty doable in PHP. And as the tags on the question suggest, you are using the right tools to do that job already.
One thing I would like to know is, why are you calling it a "proxy"? do you want to serve the content to other users?
EDIT: [update after comment]
In that case, use phproxy. It does what you want, along with a host of other features.
Problem
I need to make a proxy script that can access a page hidden behind a login screen. I do not need the proxy to "simulate" logging in, instead the login page HTML should be displayed to the user normally, and all the cookies and HTTP GET/POST data to flow through the proxy to the server, so the login should be authentic. I don't want the login/password, I only need access to the HTML source code of the pages generated after logging in. Does anybody here know how this can be accomplished? Is it easy? If not, where do I begin?* (I'm currently using PHP)*