Como ver las cabeceras HTTP de un servidor
Mediante curl o wget podemos ver las cabeceras HTTP que nos manda el servidor, sin necesidad de realizar la petición a mano mediante telnet o netcat (nc).
Usando curl con la opción -I indicamos que solo muestre las cabeceras, sin descargar la página. Por ejemplo:
$ curl -I raco.cat HTTP/1.1 200 OK Date: Thu, 01 Jan 2009 14:57:15 GMT Server: Apache/1.3.34 (Unix) PHP/5.1.2 mod_chroot/0.5 X-Powered-By: PHP/5.1.2 Set-Cookie: OJSSID=7894975318a57189df54be24c5aa8871; path=/ Content-Type: text/html; charset=utf-8 $ curl -I alcorlo.cat HTTP/1.1 302 Server: nginx/0.7.30 Date: Thu, 01 Jan 2009 14:57:23 GMT Content-Type: text/html Connection: keep-alive X-Powered-By: PHP/5.2.0-8+etch13 Location: http://www.alcorlo.cat/bloc/ $ curl -I meneame.net HTTP/1.1 200 OK Date: Thu, 01 Jan 2009 15:07:44 GMT Server: Apache X-Powered-By: PHP/5.2.4-2ubuntu5.4 Vary: Accept-Encoding Content-Type: text/html; charset=utf-8 $ curl -I www.recercat.cat HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: JSESSIONID=0090D81166F23B583AD934AF64BBC98C; Path=/ Content-Type: text/html;charset=UTF-8 Content-Language: en Transfer-Encoding: chunked Date: Thu, 01 Jan 2009 14:59:18 GMT $ curl -I systemadmin.es HTTP/1.1 200 OK Date: Thu, 01 Jan 2009 15:06:18 GMT Server: Apache X-Pingback: http://systemadmin.es/xmlrpc.php Content-Type: text/html; charset=UTF-8
Mediante wget podemos obtener el mismo efecto mediante el la opción -S. Para no descargar el contenido lo que podemos hacer es mandarlo a /dev/null:
$ wget -S systemadmin.es -O - >/dev/null
--2009-01-01 16:02:30-- http://systemadmin.es/
Resolving systemadmin.es... 91.121.113.59
Connecting to systemadmin.es|91.121.113.59|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Date: Thu, 01 Jan 2009 15:07:46 GMT
Server: Apache
X-Pingback: http://systemadmin.es/xmlrpc.php
Connection: close
Content-Type: text/html; charset=UTF-8
Length: unspecified [text/html]
Saving to: `STDOUT'
[ <=> ] 22,771 67.9K/s in 0.3s
2009-01-01 16:02:31 (67.9 KB/s) - `-' saved [22771]
Tal como vemos en los ejemplos, los headers nos pueden dar información sobre que sistema hay destrás de un web en concreto. Por ejemplo, el caso de alcorlo.cat vemos que utiliza como servidor web nginx en una Debian etch, o como meneame.net utiliza Ubuntu.
Como dato curioso podemos ver como barrapunto.com, que utiliza Slash, incluye cabeceras (X-Bender y X-Fry) con frases de Futurama:
$ curl -I barrapunto.com HTTP/1.1 200 OK Date: Thu, 01 Jan 2009 15:08:40 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e mod_perl/1.29 SLASH_LOG_DATA: shtml X-Powered-By: Slash 2.005000152 X-Bender: Well I don't have anything else planned for today, let's get drunk! Connection: close Content-Type: text/html; charset=iso-8859-1 $ curl -I barrapunto.com HTTP/1.1 200 OK Date: Thu, 01 Jan 2009 15:10:22 GMT Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e mod_perl/1.29 SLASH_LOG_DATA: shtml X-Powered-By: Slash 2.005000152 X-Fry: No, no, I was just picking my nose. Connection: close Content-Type: text/html; charset=iso-8859-1
Mañana veremos como ocultar la versión de Apache y evitar mostrar la cabecera X-Powered-By con información sobre la versión de PHP.
Relacionados
Imprimir
1. January 2009 at 9:19 pm :
Hola,
gràcies per la informació i pels exemples proposats
Una altra manera menys system admin, i més visual és utilitzar firefox i l’extensió httpfox. Que a part de les capçaleres dona més informació… És una mena d’HTTP viewer però GPL
1. January 2009 at 10:35 pm :
alternativa más cómoda todavía, instalar libwww-perl el cual trae por ejemplo el comando HEAD (symlink a un script perl), también trae para otros métodos como POST y GET. Dejo un ejemplo de la ejecución de HEAD:
$ HEAD raco.cat
200 OK
Connection: close
Date: Thu, 01 Jan 2009 20:29:09 GMT
Server: Apache/1.3.34 (Unix) PHP/5.1.2 mod_chroot/0.5
Content-Type: text/html; charset=utf-8
Client-Date: Thu, 01 Jan 2009 20:29:12 GMT
Client-Peer: 84.88.10.30:80
Client-Response-Num: 1
Set-Cookie: OJSSID=499c592beb5652310a7468ca2a2bee86; path=/
X-Powered-By: PHP/5.1.2
1. January 2009 at 10:43 pm :
Realmente interesante, tendré que provar el script POST. Tiene muy buena pinta!
Muchas gracias funky!
4. January 2009 at 3:50 am :
por qué sacar algo por stdout con wget para luego mandarlo a /dev/null ?
wget http://foo.com -O – > /dev/null
vs
wget http://foo.com -O /dev/null
no?
19. July 2010 at 8:03 am :
Seguramente por mala costumbre