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 9120395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:37:06+00:00 2026-06-17T05:37:06+00:00

I have a local development django setup with apache. The problem is that on

  • 0

I have a local development django setup with apache. The problem is that on the deployment server there is no proxy while at my workplace I work behind a http proxy, hence the request calls fail.

Is there any way of making all calls from requests library go via proxy. [ I know how to add proxy to individual calls using the proxies parameter but is there a global solution ? ]

  • 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-06-17T05:37:07+00:00Added an answer on June 17, 2026 at 5:37 am

    Add following lines in your wsgi file.

    import os
    
    http_proxy  = "10.10.1.10:3128"
    https_proxy = "10.10.1.11:1080"
    ftp_proxy   = "10.10.1.10:3128"
    
    proxyDict = { 
                  "http"  : http_proxy, 
                  "https" : https_proxy, 
                  "ftp"   : ftp_proxy
                }
    
    os.environ["PROXIES"] = proxyDict
    

    And Now you can use this environment variable anywhere you want,

    r = requests.get(url, headers=headers, proxies=os.environ.get("PROXIES"))
    

    P.S. – You should have a look at following links

    1. Official Python Documentation for Environment Variables
    2. Where and how do I set an environmental variable using mod-wsgi and django?
    3. Python ENVIRONMENT variables

    UPDATE 1

    You can do something like following so that proxy settings are only being used on localhost.

    import socket
    if socket.gethostname() == "localhost":
        # do something only on local server, e.g. setting os.environ["PROXIES"]
        os.environ["PROXIES"] = proxyDict
    else:
        # Set os.environ["PROXIES"] to an empty dictionary on other hosts
        os.environ["PROXIES"] = {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our setup as follows: We have a local development server running Ubuntu, with a
So I have a django development server that I want to be the backend
I am using Django on GAE. On my local development server I have associated
I have a really weird issue here. I'm using my local development server right
I have a little problem in my query. My database at my local development
I have the TwitterOAuth class and demonstration running on a local development server and
I have a local development environment that relies heavily on system environment variables (it
Greeting and Salutations! I work in an environment where I have a development server,
I have a development local server (WAMP) and a remote one (LAMP): even if
I have Less CSS working with my Django site in local development. Everything looks

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.