Curs: | DissenyXarxesLinux, LinuxAdministracioAvancada |
Fitxers: | ProxySquid.pdf (ProxySquid.odp) |
Repositori SVN: | http://svn.projectes.lafarga.cat/svn/iceupc/DissenyXarxaLocalLinux |
Usuari: | anonymous |
Paraula de pas: | sense paraula de pas |
Autors: | Sergi Tur Badenas |
Consulteu Configuració automàtica de clients Proxy
Seguiu aquesta manual si utilitzeu l'entorn gràfic Gnome a Ubuntu (entorn per defecte a Ubuntu).
Per tal que tot el sistema operatiu utilitzi un proxy cal anar al menú Sistema/Preferències/Servidor Intermediari de la xarxa:
Us apareixerà la següent finestra:
Feu clic a:
Configuració manual del servidor intermediari
I escolliu l'opció:
Empra el mateix servidor intermediari per a tots els protocols
Ompliu les caixetes amb els següents valors:
La finestra us ha de quedar de la següent forma:
Un cop ho tingueu feu clic al botó Tanca.
Ja teniu configurat el vostre sistema.
Podeu consultar els paràmetres del proxy de Gnome executant:
$ gconf-editor
A l'apartat System/http_proxy torbareu les dades del proxy del sistema:
TODO:
$ cat .gconf/system/http_proxy/%gconf.xml
This will be the same as:
The proxy configuration can be divided into two parts:
. /system/proxy/ - Configures SOCKS Proxy . /system/http_proxy/ - Configures HTTP proxy
We can use gconftool -R to view the options within the subkeys. For the screenshot above we would get something similar to this:
$ gconftool -R /system/proxy old_ftp_port = 0 socks_host = 127.0.0.1 mode = manual old_socks_port = 0 secure_host = 127.0.0.1 ftp_host = 127.0.0.1 socks_port = 80 old_secure_host = secure_port = 80 ftp_port = 80 old_ftp_host = autoconfig_url = old_secure_port = 0 old_socks_host = $ gconftool -R /system/http_proxy use_http_proxy = true use_authentication = false host = 127.0.0.1 authentication_user = ignore_hosts = [localhost,127.0.0.0/8,*.local] use_same_proxy = true authentication_password = port = 80
So, to edit the proxy to the same settings as the one shown on the screenshot, we would do the following:
$ gconftool -s /system/http_proxy/use_http_proxy -t bool true $ gconftool -s /system/http_proxy/host -t int 127.0.0.1 $ gconftool -s /system/http_proxy/port -t int 80 $ gconftool -s /system/http_proxy/use_same_proxy -t bool true $ gconf -s /system/proxy/mode -t string manual
Per fer-ho mandatory?:
$ gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/http_proxy/host proxy-name $ gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/http_proxy/port proxy-port
Si disposeu de Kubuntu (KDe), les passes a seguir per configurar el proxy del sistema són:
Aneu al configurador del sistema (Arranjament del Sistema). El podeu trobar al menú de KDE:
Ara seleccioneu l'opció Paràmetres de xarxa:
Us apareixerà la següent finestra:
Ara feu clic a:
I poseu els següents valors:
Ja teniu el proxy del sistema configurat.
Executeu les següents comandes:
$ sudo apt-get install kde-systemsettings $ systemsettings
I seguiu les passes de l'apartat KDE per tal de configurar el proxy.
$ cat /etc/apt/apt.conf Acquire::http::Proxy "http://192.168.203.1:3128";
NOTA: Si no s'especifica Acquire::http::Proxy, segons el manual aleshores s'utilitzarà la variable d'entorn http_proxy (o ftp_proxy si el repositori és ftp)
TODO Error: Some index files failed to download, they have been ignored, or old ones used instead.
Solucions:
$ sudo apt-get update -o Acquire::http::No-Cache=True
O:
$ cat /etc/apt/apt.conf APT { // Options for the downloading routines Acquire { http { No-Cache "true"; }; }; }
Del manual de apt-conf:
$ man apt.conf ... http HTTP URIs; http::Proxy is the default http proxy to use. It is in the standard form of http://[[user][:pass]@]host[:port]/. Per host proxies can also be specified by using the form http::Proxy::<host> with the special keyword DIRECT meaning to use no proxies. If no one of the above settings is specified, http_proxy environment variable will be used. Three settings are provided for cache control with HTTP/1.1 compliant proxy caches. No-Cache tells the proxy to not use its cached response under any circumstances, Max-Age is sent only for index files and tells the cache to refresh its object if it is older than the given number of seconds. Debian updates its index files daily so the default is 1 day. No-Store specifies that the cache should never store this request, it is only set for archive files. This may be useful to prevent polluting a proxy cache with very large .deb files. Note: Squid 2.0.2 does not support any of these options. The option timeout sets the timeout timer used by the method, this applies to all things including connection timeout and data timeout. One setting is provided to control the pipeline depth in cases where the remote server is not RFC conforming or buggy (such as Squid 2.0.2). Acquire::http::Pipeline-Depth can be a value from 0 to 5 indicating how many outstanding requests APT should send. A value of zero MUST be specified if the remote host does not properly linger on TCP connections - otherwise data corruption will occur. Hosts which require this are in violation of RFC 2068.
$ cat /etc/apt/apt.conf.d/30proxy Acquire { http { Proxy "http://192.168.203.1:3128"; Proxy::es.archive.ubuntu.com "DIRECT"; Proxy::security.ubuntu.com "DIRECT"; } }
Automàtic:
yast->network services->intermediari i omplir les diferencies opcions amb la @ip i el port del proxy
Manual:
Al fitxer
/etc/sysconfig/proxy
i poses les mateixes dades que abans dins les variables adients.
Assegureu-vos d'haver configurat prèviament el proxy del vostre sistema operatiu. Consulteu els següents apartats d'aquest manual:
Per tal de configurar el proxy heu d'anar a un dels següents menús, depenent del vostre sistema operatiu:
Ubuntu | Windows |
---|---|
Us apareixerà la següent finestra:
Ubuntu | Windows |
---|---|
Ara heu de fer clic al menú Avançat/Avanzado i seleccioneu la pestanya Xarxa/Red:
Ubuntu | Windows |
---|---|
Ara feu clic al botó Paràmetres/Connexió. Us apareixerà la següent finestra:
Ubuntu | Windows |
---|---|
Aquí teniu 2 opcions:
Ubuntu | Windows |
---|---|
Feu clic a Aceptar per tancar la primera finestra i un altre cop a Aceptar per tancar la configuració de Firefox. Ja teniu el Firefox configurat.
Els valors del proxy es guarden a:
network.proxy.*
Els més importants són:
network.proxy.http network.proxy.http_port network.proxy.no_proxies_on
També hi ha:
network.proxy.backup.*
Que guarda l'últim proxy utilitzat.
TODO:
1. open about:config 2. set network.automatic-ntlm-auth.allow-proxies to false 3. set network.proxy.share_proxy_settings to false
Els profiles (perfils) es troben a:
Windows: %APPDATA%\Mozilla\Firefox\Profiles\"Profile name"\ Unix : ~/.mozilla/firefox/"Profile name"/
La configuració es guarda al fitxer prefs.js :
$ grep -n "proxy" -r . | more grep: ./lock: No such file or directory ./prefs.js:38:user_pref("network.proxy.backup.ftp", "192.168.1.5"); ./prefs.js:39:user_pref("network.proxy.backup.ftp_port", 3128); ./prefs.js:40:user_pref("network.proxy.backup.gopher", "192.168.1.5"); ./prefs.js:41:user_pref("network.proxy.backup.gopher_port", 3128); ./prefs.js:42:user_pref("network.proxy.backup.socks", "192.168.1.5"); ./prefs.js:43:user_pref("network.proxy.backup.socks_port", 3128); ./prefs.js:44:user_pref("network.proxy.backup.ssl", "192.168.1.5"); ./prefs.js:45:user_pref("network.proxy.backup.ssl_port", 3128); ./prefs.js:46:user_pref("network.proxy.ftp", "192.168.1.5"); ./prefs.js:47:user_pref("network.proxy.ftp_port", 3128); ./prefs.js:48:user_pref("network.proxy.gopher", "192.168.1.5"); ./prefs.js:49:user_pref("network.proxy.gopher_port", 3128); ./prefs.js:50:user_pref("network.proxy.http", "192.168.1.5"); . /prefs.js:51:user_pref("network.proxy.http_port", 3128); . /prefs.js:52:user_pref("network.proxy.no_proxies_on", "localhost, 127.0.0.1,192.168.1.0/24"); . /prefs.js:53:user_pref("network.proxy.share_proxy_settings", true); . /prefs.js:54:user_pref("network.proxy.socks", "192.168.1.5"); . /prefs.js:55:user_pref("network.proxy.socks_port", 3128); . /prefs.js:56:user_pref("network.proxy.ssl", "192.168.1.5"); . /prefs.js:57:user_pref("network.proxy.ssl_port", 3128); . /prefs.js:58:user_pref("network.proxy.type", 0);
Per tal que tot el sistema i tots els usuaris utilitzin el proxy cal afegir al fitxer:
/etc/bash.bashrc
Les línies:
export http_proxy=http://192.168.11.1:800/ export no_proxy=localhost,127.0.0.0/8,*.local,192.168.0.0/16
NOTA: Abans (veure el següent http_proxy manava sobre la configuració especifica de APT. Sembla que ja no és així). Vegeu:
bug
http://imasproxy.imas.es/proxy.pac
function FindProxyForURL(url, host) { if ( isInNet(host, "10.0.0.0", "255.0.0.0") || dnsDomainIs(host, ".imas.es") || isInNet(host, "192.168.0.0","255.255.0.0") || dnsDomainIs(host,".imasbcn.cat") || dnsDomainIs(host,".imasbcn.org") || dnsDomainIs(host,".imasbcn.com") || isInNet(host, "193.146.191.50","255.255.255.255")) { return "DIRECT"; } else { return "PROXY imasproxy1.imas.es:3128; PROXY imasproxy1.imas.es:3128; PROXY imasproxy1.imas.es:3128"; } }
Un altre:
http://www.xtec.es/proxy.pac
function FindProxyForURL(url, host) { if ((url.substring(0, 5) != "http:") && (url.substring(0,4) != "ftp:") && (url.substring(0,6) != "https:")) { return "DIRECT"; } if (isPlainHostName(host) || dnsDomainIs(host, ".xtec.es") || dnsDomainIs(host, ".edu365.com") || dnsDomainIs(host, ".intranet") || dnsDomainIs(host, ".gencat.es") || dnsDomainIs (host, ".gencat.net") || dnsDomainIs(host, ".cambrescat.es") || shExpMatch(host, "127.*")) return "DIRECT"; else return "DIRECT"; }
Exemple:
$ env | grep proxy http_proxy=http://sergi:[email protected]:3128/ no_proxy=localhost,127.0.0.0/8,*.local
NOTA: Fixeu-vos que es pot indicar l'usuari i paraula de pas. La paraula de as no es guarda xifrada
Es poden establir les variables d'entorn als fitxers .bashrc (a nivell d'usuari) o a /etc/bash.bashrc (a nivell de sistema) utilitzant export:
export http_proxy=http://DOMAIN\USERNAME:[email protected]:PORT/
NOTA: Cal no oblidar altres protocols com FTP:
export ftp_proxy=http://DOMAIN\USERNAME:[email protected]:PORT/
Es pot ometre DOMAIN\USERNAME:[email protected] si no s'utilitza autenticació al proxy
Des de la línia d'ordres de DOS (Tecla Windows+R i escriure cmd):
control inetcpl.cpl
Consulteu:
Configuració_automàtica_de_clients_Proxy#Windows
Recursos:
Consulteu: Wget#Proxy
Si només es pot navegar per proxy (és a dir un firewall tipus iptables només permet navegació a través del port del proxy (Squid)), trobareu errors similars :
$ wget http://www.upc.edu --2010-11-12 20:55:45-- http://www.upc.edu/ Resolving www.upc.edu... 147.83.2.135, 2001:40b0:7500:1::21 Connecting to www.upc.edu|147.83.2.135|:80...
Fixeu-vos que la resol·lució del DNS funciona (el firewall deixa utilizar DNS però no el port 80). L'única sol·lució que tenen els usuaris és utilitzar el proxy:
$ export http_proxy="http://192.168.203.1:3128/" $ wget http://www.upc.edu --2010-11-12 20:58:27-- http://www.upc.edu/ Connecting to 192.168.203.1:3128... connected. Proxy request sent, awaiting response... 200 OK Length: 48900 (48K) [text/html] Saving to: `index.html.2' ... 2010-11-12 20:58:27 (122 MB/s) - `index.html.2' saved [48900/48900]
NOTA: provat a una Ubuntu Server 10.10 i una 10.4 Desktop
Utilitza les variables d'entorn:
$ wget --proxy-user "DOMAIN\USERNAME" --proxy-passwd "PASSWORD" URL
Vegeu també Wget#Proxy
El problema és que alguns paquets com flashplugin-nonfree o msttcorefonts utilitzant wget i si no està ben configurat wget per utilitzar proxy a nivell de sistema (vegeu apartat anterior) aleshores no funcionen aquests paquets
TODO
Vegeu també apt.