How do I write a simple PHP transparent proxy?

后端 未结 4 685
迷失自我
迷失自我 2021-01-06 06:04

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

4条回答
  •  囚心锁ツ
    2021-01-06 07:05

    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.

提交回复
热议问题