• December 22, 2024

Proxy Environment Variable

Using the cf CLI with a Proxy Server | Cloud Foundry Docs

Overview
Format of _proxy
Use SOCKS5 with cf v3-ssh
Set _proxy in Mac OS or Linux
Set _proxy in Windows
Page last updated:
This topic describes using the Cloud Foundry Command Line Interface (cf CLI) with a proxy server.
If you have an HTTP or SOCKS5 proxy server on your network between a host running the cf CLI and your API endpoint, you must set _proxy with the hostname or IP address of the proxy server. The _proxy environment variable holds the hostname or IP address of your proxy server.
_proxy is a standard environment variable. Like any environment variable, the specific steps you use to set it depends on your operating system.
_proxy is set with hostname or IP address of the proxy server in URL format, as in the example below:
_proxy=
If the proxy server requires a username and password, you must include the credentials, as in the example below:
If the proxy server uses a port other than 80, you must include the port number, as in the example below:
If the proxy server is a SOCKS5 proxy, you must specify the SOCKS5 protocol in the URL, as in the example below:
_proxy=socks5
The cf v3-ssh command in cf CLI v6 supports SOCKS5 proxies.
To specify the SOCKS5 proxy server:
Set the all_proxy environment variable, as in the example below:
all_proxy=socks5
Note: The cf ssh command for cf CLI v7 does not work through a SOCKS5 proxy.
To set the _proxy environment variable in Mac OS or Linux:
Use the command specific to your shell. For example, in bash, use the export command, as in the example below:
export _proxy=
To make this change persistent, add the command to the appropriate profile file for the shell. For example, in bash, add a line like example below to your. bash_profile or file:
_proxy=username:password@hostname:port
export $_proxy
To set the _proxy environment variable in Windows:
Open the Start menu.
Right-click Computer and select Properties.
In the left pane of the System window, click Advanced system settings.
In the System Properties window:
Select Advanced.
Click Environment Variables.
Under User variables, click New.
For Variable name, enter _proxy.
For Variable value, enter your proxy server information.
Click OK.
Create a pull request or raise an issue on the source for this page in GitHub
How to set up proxy using http_proxy & https_proxy ...

How to set up proxy using http_proxy & https_proxy …

What is Proxy Server? Check current proxy configuration status (_proxy/_proxy)Set up proxy server using _proxy environment variableSet up proxy without username and passwordSet up proxy with username and passwordSet up proxy with domain, username and passwordSpecial character (@) handlingSet up proxy permanently using /etc/environmentSet up proxy permanently using /etc/profile. d
In this article I will share the steps to set up proxy server using _proxy and _proxy environment variable.
What is Proxy Server?
A proxy server is a dedicated computer or a software system running on a computer that acts as an intermediary between an endpoint device, such as a computer, and another server from which a user or client is requesting a service. The proxy server may exist in the same machine as a firewall server or it may be on a separate server, which forwards requests through the firewall.
Check current proxy configuration status (_proxy/_proxy)
This variable will show if there is a proxy server configured on the system:
# echo $_proxy
If these variables are empty it would mean that there are no proxy servers configured on the system level.
Set up proxy server using _proxy environment variable
The _proxy and _proxy environment variable is used to specify proxy settings to client programs such as curl and wget.
Set up proxy without username and password
Execute the below command with valid SERVER_IP and PORT on the terminal. This will enable proxy configuration for the current session but these values will not be persistent across reboot.
# export _proxy=SERVER:PORT/
Set up proxy with username and password
You can modify the earlier command to add the username and password value assuming a valid authentication is required to enable the proxy server configuration. But again this command will also enable proxy server for the current session only and will not be persistent across reboots.
# export _proxy=USERNAME:PASSWORD@SERVER:PORT/
Set up proxy with domain, username and password
Assuming you are also required to add domain detail while setting up proxy configuration on your system then use the below command
# export _proxy=DOMAIN\\USERNAME:PASSWORD@SERVER:PORT/
Special character (@) handling
With more complex and robust handling of special characters in username or password follow How to setup or proxy with special characters in username and password
When the username or password uses the @ symbol, add a backslash (\) before the @ – for example:
export _proxy=DOMAIN\\USERN\@ME:PASSWORD@SERVER:PORT
or
export _proxy=DOMAIN\\USERNAME:P\@SSWORD@SERVER:PORT
Set up proxy permanently using /etc/environment
Now as I have highlighted above the above commands will work only for the current active session but will not be available across reboots. So to make these changes persistent define the environment variables in /etc/environment file:
# echo “_proxy= >> /etc/environment
HINT:Here /etc/environment file is NOT a shell script and applies to all processes without shell.
Set up proxy permanently using /etc/profile. d
For bash and sh users, add the export line given above into a new file called /etc/profile. d/ file:
# echo “export _proxy= > /etc/profile. d/
For csh and tcsh users, use the following command to set the _proxy variable in a new file called /etc/profile. d/ file:
# echo “setenv _proxy > /etc/profile. d/
The extension of these files determines which shell will read them. The commands are not interchangeable.
HINT:Replace _proxy with _proxy in the export argument to enable proxy over SSL/TLS. This information will be provided by the Network Team who have provided the proxy server related details.
Lastly I hope the steps from the article to setup proxy using _proxy and _proxy environment variable in Linux was helpful. So, let me know your suggestions and feedback using the comment section.
Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud
How to Set Up a Proxy Server (System Administration Guide

How to Set Up a Proxy Server (System Administration Guide

How to Set Up a Proxy Server
If your system is behind a firewall with a proxy, you will need to set
up a proxy server before you can add a package from an HTTP server.
Become superuser or assume an equivalent role.
Select one of the following methods to specify a proxy server.
Specify the proxy server by using the _proxy, HTTPPROXY, or HTTPPROXYPORT environment variable.
For example:
# setenv _proxy
Or, specify one of the following:
# setenv HTTPPROXY
# setenv HTTPPROXYPORT 8080
Specify the proxy server on the pkgadd -x command line.
# pkgadd -x -d SUNWpkg
Create a admin file that includes proxy server information.
# cat /tmp/admin
mail=
instance=unique
partial=ask
runlevel=ask
idepend=ask
rdepend=ask
space=ask
setuid=ask
conflict=ask
action=ask
networktimeout=60
networkretries=3
authentication=quit
keystore=/var/sadm/security
basedir=default
Then, identify the admin file with the pkgadd -a command. For example:
# pkgadd -a /tmp/admin -d SUNWpkg

Frequently Asked Questions about proxy environment variable

What is proxy environment variable?

The http_proxy and https_proxy environment variable is used to specify proxy settings to client programs such as curl and wget .

How do I set up an Env proxy?

How to Set Up a Proxy ServerBecome superuser or assume an equivalent role.Select one of the following methods to specify a proxy server. Specify the proxy server by using the http_proxy, HTTPPROXY, or HTTPPROXYPORT environment variable. For example: # setenv http_proxy http: //mycache.domain:8080.

What is Http_proxy variable?

The http_proxy variable tells the system what proxy server it should used to fetch URLs on the command line. This allows you to manually download a file via http, https and ftp and also allows most other command line programs to get files from the internet (for example the yum command to update you Linux system).Sep 15, 2012

Leave a Reply