Description:

This document answers common questions about proxy servers and explains how they affect internet access within our organization. In simple terms, a proxy server acts as an intermediary between your computer and the internet. Instead of directly connecting to a website or online service, your request is first sent to the proxy server. The proxy server then forwards the request on your behalf and delivers the response back to you. Think of it like a translator: you speak to the translator (the proxy), and they communicate with the other party (the internet) for you.
Our organization uses proxy servers primarily to enhance security and manage internet access. Here are the key reasons:
While proxies provide benefits, they can also cause issues for both regular users and developers:
Website Access Issues: You may be unable to access certain websites because the proxy server is blocking them. This could be due to content filtering policies (e.g., the company blocks social media) or technical issues with the proxy server itself.
Slow Internet Speeds: Proxy servers can sometimes slow down internet speeds, especially if the proxy server is overloaded, located far away, or if it’s inspecting all the traffic.
Website Functionality Issues: Some websites may not work correctly when accessed through a proxy server. This can manifest in several ways:
API Request Failures: Your application might fail to make API requests to external services. This can happen for a few reasons:
SSL Certificate Errors: You might encounter SSL certificate errors when trying to access HTTPS resources. This can occur if the proxy server is intercepting and re-signing SSL certificates, and your development environment doesn’t trust the proxy’s certificate [1].
Build and Package Manager Issues: Tools like npm, pip, or maven might fail to download dependencies or publish packages. This is often due to the proxy server interfering with the package manager’s network requests [2]. Again, this is often due to missing proxy configurations for these specific tools.
To summarize the reasons, developers often face these issues because:
This document shares my experiences troubleshooting proxy issues. I’ve found that problems can arise at both the operating system and application levels. The OS-Level Troubleshooting section covers the issues I’ve encountered as a general user, while the Application-Level Troubleshooting section details what I’ve learned as a developer configuring applications to work with proxies.
This section covers the proxy-related issues I’ve encountered as a general computer user.
Purpose: To ensure the operating system is correctly configured to use the proxy server. This is a prerequisite for applications to successfully use the proxy.
Checking Proxy Settings:
Windows:
Linux:
echo $http_proxyecho $https_proxyecho $no_proxyhttp://proxy.example.com:8080). no_proxy contains a comma-separated list of domains or IP addresses that should bypass the proxy.Setting Proxy Settings (If Necessary):
Windows:
Linux:
~/.bashrc or ~/.zshrc):
nano ~/.bashrc (or nano ~/.zshrc)export http_proxy=http://proxy.example.com:8080
export https_proxy=http://proxy.example.com:8080
export no_proxy="localhost,127.0.0.1,*.example.com" # Optional: Bypass the proxy for these addresses
source ~/.bashrc (or source ~/.zshrc)This section shares my experiences as a developer configuring applications to work with a proxy server.
Purpose: To configure individual applications to use the OS-level proxy settings or to override them with specific proxy settings.
General Testing:
Use curl or wget to test basic connectivity through the proxy. If these tools are not installed, you may need to install them using your operating system’s package manager (e.g., apt, yum, brew).
curl -v http://www.example.com (The -v option provides verbose output, showing the proxy being used)wget http://www.example.comLanguage-Specific Configuration:
Java:
java -Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=proxy.example.com -Dhttps.proxyPort=8080 YourApp.jar
settings.xml file (usually located in ~/.m2/):
<settings>
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<!--
<username>proxyuser</username>
<password>somepassword</password>
-->
<nonProxyHosts>localhost|127.0.0.1|*.example.com</nonProxyHosts>
</proxy>
</proxies>
</settings>
gradle.properties file (usually located in ~/.gradle/):
systemProp.http.proxyHost=proxy.example.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.example.com
systemProp.https.proxyPort=8080
systemProp.http.nonProxyHosts=localhost|127.0.0.1|*.example.com
Python:
requests library:
import requests
proxies = {
'http': 'http://proxy.example.com:8080',
'https': 'http://proxy.example.com:8080',
}
try:
response = requests.get('http://www.example.com', proxies=proxies)
response.raise_for_status() ## Raise HTTPError for bad responses (4xx or 5xx)
print(response.text)
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
requests library (and many other Python libraries) will automatically use the http_proxy and https_proxy environment variables if they are set.pip: You can configure pip to use a proxy by setting environment variables or using command-line options.
http_proxy, https_proxy, and no_proxy environment variables. These can be set as described in the OS-Level Troubleshooting section for Linux.bash pip install --proxy http://proxy.example.com:8080 <package_name> ~/.pip/pip.conf on Linux/macOS or %APPDATA%\pip\pip.ini on Windows): ini [global] proxy = http://proxy.example.com:8080 By understanding how proxy servers work and following these troubleshooting steps, you can minimize the impact of proxy-related issues and stay productive.