Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 331035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:44:13+00:00 2026-05-12T09:44:13+00:00

At work we have to use a proxy to basically access port 80 for

  • 0

At work we have to use a proxy to basically access port 80 for example, we have our own custom logins for each user.

My temporary workaround is using curl to basically login as myself through a proxy and access the external data I need.

Is there some sort of advanced php setting I can set so that internally whenever it tries to invoke something like file_get_contents() it always goes through a proxy? I’m on Windows ATM so it’d be a pain to recompile if that’s the only way.

The reason my workaround is temporary is because I need a solution that’s generic and works for multiple users instead of using one user’s credentials (I’ve considered requesting a separate user account solely to do this but passwords change often and this technique needs to be deployed throughout a dozen or more sites). I don’t want to hard-code credentials basically to use the curl workaround.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:44:13+00:00Added an answer on May 12, 2026 at 9:44 am

    To use file_get_contents() over/through a proxy that doesn’t require authentication, something like this should do :

    (I’m not able to test this one : my proxy requires an authentication)

    $aContext = array(
        'http' => array(
            'proxy'           => 'tcp://192.168.0.2:3128',
            'request_fulluri' => true,
        ),
    );
    $cxContext = stream_context_create($aContext);
    
    $sFile = file_get_contents("http://www.google.com", False, $cxContext);
    
    echo $sFile;
    

    Of course, replacing the IP and port of my proxy by those which are OK for yours 😉

    If you’re getting that kind of error :

    Warning: file_get_contents(http://www.google.com) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 407 Proxy Authentication Required
    

    It means your proxy requires an authentication.

    If the proxy requires an authentication, you’ll have to add a couple of lines, like this :

    $auth = base64_encode('LOGIN:PASSWORD');
    
    $aContext = array(
        'http' => array(
            'proxy'           => 'tcp://192.168.0.2:3128',
            'request_fulluri' => true,
            'header'          => "Proxy-Authorization: Basic $auth",
        ),
    );
    $cxContext = stream_context_create($aContext);
    
    $sFile = file_get_contents("http://www.google.com", False, $cxContext);
    
    echo $sFile;
    

    Same thing about IP and port, and, this time, also LOGIN and PASSWORD 😉 Check out all valid http options.

    Now, you are passing an Proxy-Authorization header to the proxy, containing your login and password.

    And… The page should be displayed 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a few MSBuild custom tasks that work well and are use
We have a tech support website/database at work that we use to record our
I have been trying to use a formula that is used to work out
I use Eclipse 3.3 in my daily work, and have also used Eclipse 3.2
I work on a web game , I use asp.net mvc, linqtosql. I have
So I've tried to work with the pure-CSS, never-use-tables-for-layout gospel, I really have. But
Traditionally, when we use SQL string to done some work, we have to close
I would like to use Charles web proxy to work with the Android emulator
I have an internal proxy that fetches data from my own server and displays
I need web access from Gradle through a proxy server to use the Gradle/Artifactory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.