Difference between revisions of "Proxy settings"

From ArchWiki
Jump to: navigation, search
(recat (there are a few proxy server articles))
(merging in Using a SOCKS proxy)
Line 1: Line 1:
 
[[Category:Proxy servers (English)]]
 
[[Category:Proxy servers (English)]]
 
{{expansion}}
 
{{expansion}}
=Introduction=
+
==Introduction==
 
A proxy is "an interface for a service, especially for one that is remote, resource-intensive, or otherwise difficult to use directly". Source: [http://en.wiktionary.org/wiki/proxy Proxy - Wiktionary].
 
A proxy is "an interface for a service, especially for one that is remote, resource-intensive, or otherwise difficult to use directly". Source: [http://en.wiktionary.org/wiki/proxy Proxy - Wiktionary].
  
=Environment variables=
+
==Environment variables==
 
Some programs (like [[wget]]) use environment variables of the form "protocol_proxy" to determine the proxy for a given protocol (e.g. HTTP, FTP, ...).
 
Some programs (like [[wget]]) use environment variables of the form "protocol_proxy" to determine the proxy for a given protocol (e.g. HTTP, FTP, ...).
  
Line 35: Line 35:
  
  
==Automation with network managers==
+
===Automation with network managers===
 
*[[NetworkManager]] can't change the environment variables.
 
*[[NetworkManager]] can't change the environment variables.
 
*[[netcfg]] could set-up these environment variables but they would not be seen by other applications as they are not child of netcfg.
 
*[[netcfg]] could set-up these environment variables but they would not be seen by other applications as they are not child of netcfg.
Line 54: Line 54:
 
* For a simple proxy, ssh with port forwarding can be used
 
* For a simple proxy, ssh with port forwarding can be used
  
== Simple Proxy with SSH ==
+
=== Simple Proxy with SSH ===
 
Connect to a server (HOST) on which you have an account (USER) as follows
 
Connect to a server (HOST) on which you have an account (USER) as follows
 
  ssh -D PORT USER@HOST
 
  ssh -D PORT USER@HOST
 
For PORT, choose some number which is not an IANA registered port. This specifies that traffic on the local PORT will be forwarded to the remote HOST. ssh will act as a [[Wikipedia:SOCKS|SOCKS]] server. Software supporting SOCKS proxy servers can simply be configured to connect to PORT on localhost.
 
For PORT, choose some number which is not an IANA registered port. This specifies that traffic on the local PORT will be forwarded to the remote HOST. ssh will act as a [[Wikipedia:SOCKS|SOCKS]] server. Software supporting SOCKS proxy servers can simply be configured to connect to PORT on localhost.
 +
 +
==Using a SOCKS proxy==
 +
There are two cases:
 +
*the application you want to use handles SOCKS proxies (for example Firefox) then you just have to configure it to use the proxy
 +
*the application you want to use does not handle SOCKS proxies then you can try to use [http://tsocks.sourceforge.net/ tsocks] (available in extra)

Revision as of 01:40, 8 September 2011

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:Proxy settings#)

Introduction

A proxy is "an interface for a service, especially for one that is remote, resource-intensive, or otherwise difficult to use directly". Source: Proxy - Wiktionary.

Environment variables

Some programs (like wget) use environment variables of the form "protocol_proxy" to determine the proxy for a given protocol (e.g. HTTP, FTP, ...).

Below is an example on how to set these variables in a shell:

 export http_proxy=http://10.203.0.1:5187/
 export ftp_proxy=http://10.203.0.1:5187/

Some programs look for the all caps version of the environment variables.

Alternatively you can automate the toggling of the variables by adding a function to your .bashrc (thanks to Alan Pope)

function proxy(){
    echo -n "username:"
    read -e username
    echo -n "password:"
    read -es password
    export http_proxy="http://$username:$password@proxyserver:8080/"
    export ftp_proxy="http://$username:$password@proxyserver:8080/"
    echo -e "\nProxy environment variable set."
}
function proxyoff(){
    unset HTTP_PROXY
    unset http_proxy
    unset FTP_PROXY
    unset ftp_proxy
    echo -e "\nProxy environment variable removed."
}

If you don't need a password then omit it.


Automation with network managers

  • NetworkManager can't change the environment variables.
  • netcfg could set-up these environment variables but they would not be seen by other applications as they are not child of netcfg.

About libproxy

libproxy (which is available in the extra repository) is an abstraction library which should be used by all applications that want to access a network resource. It still is in development but could lead to a unified and automated handling of proxies in GNU/Linux if widely adopted.

The role of libproxy is to read the proxy settings form different sources and make them available to applications which use the library. The interesting part with libproxy is that it offers an implementation of the Web Proxy Autodiscovery Protocol and an implementation of Proxy Auto-Config that goes with it.

The Template:Codeline binary takes URL(s) as argument(s) and returns the proxy/proxies that could be used to fetch this/these network resource(s).

Note: the 0.2.3-1 version doesn't work for me.

As of 06/04/2009 libproxy is required by libsoup. It is then indirectly used by the Midori browser.

Web Proxy Options

  • Squid is a very popular caching/optimizing proxy
  • Privoxy is an anonymizing and ad-blocking proxy
  • For a simple proxy, ssh with port forwarding can be used

Simple Proxy with SSH

Connect to a server (HOST) on which you have an account (USER) as follows

ssh -D PORT USER@HOST

For PORT, choose some number which is not an IANA registered port. This specifies that traffic on the local PORT will be forwarded to the remote HOST. ssh will act as a SOCKS server. Software supporting SOCKS proxy servers can simply be configured to connect to PORT on localhost.

Using a SOCKS proxy

There are two cases:

  • the application you want to use handles SOCKS proxies (for example Firefox) then you just have to configure it to use the proxy
  • the application you want to use does not handle SOCKS proxies then you can try to use tsocks (available in extra)