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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 156k
  • Answers 157k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you want to use the $Logger from within an… May 12, 2026 at 10:58 am
  • Editorial Team
    Editorial Team added an answer >>> import platform >>> platform.system() 'Windows' May 12, 2026 at 10:58 am
  • Editorial Team
    Editorial Team added an answer If all you want to do is move a background… May 12, 2026 at 10:58 am

Related Questions

I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I
At work I'm dipping my toes in managing project dependencies with maven. We use
We use a simple object model for our low level networking code at work
I'm trying to create a web application project template for everyone to use here
I've asked a few questions on this topic before. Before we're able to implement

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.