internet e architetture di rete la ragazza della porta ottanta: http

31
Internet e architetture di rete Antonio Prado https://www.prado.it Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Upload: antonio-prado

Post on 29-Jan-2018

105 views

Category:

Internet


2 download

TRANSCRIPT

Page 1: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Internet e architetture di

reteAntonio Prado

https://www.prado.it

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 2: Internet e architetture di rete la ragazza della porta ottanta: HTTP

La ragazza della porta ottanta: HTTP

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 3: Internet e architetture di rete la ragazza della porta ottanta: HTTP

TCP/UDP 80[Tim_Berners_Lee]

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 4: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Tim Berners-Lee, inventore del World Wide Web[RFC 1630, 1738, 1866, 1945, 2068, 2396, 2616, 3986 ]

URI

URLHTML

HTTP

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 5: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Hypertext Transfer Protocol -- HTTP/1.0[RFC 1945]

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 6: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Hypertext Transfer Protocol -- HTTP/1.1[RFC 2616]

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 7: Internet e architetture di rete la ragazza della porta ottanta: HTTP

RFC 1945HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification reflects common usage of the protocol referred to as "HTTP/1.0".

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 8: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Universal Resource IdentifierURI ASSOLUTOscheme://hostname[:port]/pathhttp://www.paperino.it:80/qui/quo/qua

URI RELATIVO/qui/qui/quo/qui/quo/qua

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 9: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Uniform Resource Locatorhttp_URL="http:""//"host[":"port][abs_path]

HTTP message typesHTTP messages consist of requests from client to server and responses from server to client.

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 10: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Il WEB server è un HTTP server

Protocollo a livello applicativo

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 11: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Domanda e Risposta1. Il client fa una domanda2. Il server risponde

Il protocollo HTTP supporta più scambi domanda/risposta su una singola sessione TCP

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 12: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Domanda e RispostaDomanda HTTP 1.0

Righe di testo (ASCII)

Fine riga con CRLF \r\n

Prima riga: Request-Line

Request-LineIntestazioniRiga vuotaContenuto

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 13: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Metodi nella domandaGET recupera informazioni indicate dalla URIHEAD recupera meta-informazioni sulla URIPOST invia informazioni alla URI e recupera il risultatoPUT Archivia informazioni nel posto nominato dalla URIDELETE rimuove l’entità indicata dalla URITRACE traccia HTTP inoltrato attraverso proxy, tunnel eccOPTIONS determina le capacità del server o le caratteristiche di una risorsa

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 14: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Telnet LAB

telnet as59715.net 80Trying 2a02:cdc5:9715:1:250:56ff:fe97:2298...Connected to as59715.net.Escape character is '^]'.GET / HTTP/1.1Host: as59715.net[CRLF]HTTP/1.1 301 Moved PermanentlyDate: Sat, 28 May 2016 04:49:11 GMTServer: Apache/2.4.20 (FreeBSD) OpenSSL/1.0.1e-freebsd PHP/5.4.45Location: https://as59715.net/Content-Length: 228Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>301 Moved Permanently</title></head><body><h1>Moved Permanently</h1><p>The document has moved <a href="https://as59715.net/">here</a>.</p></body></html>Connection closed by foreign host.

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 15: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP server

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 16: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP server LABInstalla lighttpd

Redhat [e derivati] yum install lighttpdDebian [e derivati] apt-get install lighttpdFreeBSD pkg install lighttpd

Localizza e modifica il file lighttpd.conf

Redhat e Debian /etc/lighttpd/lighttpd.confFreeBSD /usr/local/etc/lighttpd/lighttpd.conf

Avvia il demone lighttpd

Redhat e Debian systemctl start lighttpd.serviceFreeBSD echo ‘lighttpd_enable=YES’ >> /etc/rc.conf && /usr/local/etc/rc.d/lighttpd start

A

B

CAntonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 17: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Installa lighttpd

Redhat [e derivati] yum install lighttpdDebian [e derivati] apt-get install lighttpdFreeBSD pkg install lighttpd

HTTP server LAB

Aapt-get install lighttpdReading package lists... DoneBuilding dependency tree Reading state information... DoneSuggested packages: rrdtool apache2-utilsThe following NEW packages will be installed: lighttpd0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.Need to get 0 B/227 kB of archives.After this operation, 915 kB of additional disk space will be used.Selecting previously unselected package lighttpd.(Reading database ... 203113 files and directories currently installed.)Preparing to unpack .../lighttpd_1.4.33-1+nmu2ubuntu2_amd64.deb ...Unpacking lighttpd (1.4.33-1+nmu2ubuntu2) ...Processing triggers for ufw (0.34~rc-0ubuntu2) ...Processing triggers for ureadahead (0.100.0-16) ...ureadahead will be reprofiled on next rebootProcessing triggers for man-db (2.6.7.1-1ubuntu1) ...Setting up lighttpd (1.4.33-1+nmu2ubuntu2) ... * Starting web server lighttpd

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 18: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP server LAB

Localizza e modifica il file lighttpd.conf

Redhat e Debian /etc/lighttpd/lighttpd.confFreeBSD /usr/local/etc/lighttpd/lighttpd.conf

server.document-root = "/var/www"server.upload-dirs = ( "/var/cache/lighttpd/uploads" )server.errorlog = "/var/log/lighttpd/error.log"server.pid-file = "/var/run/lighttpd.pid"server.username = "www-data"server.groupname = "www-data"server.port = 80

B

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 19: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP server LABAvvia il demone lighttpd

Redhat e Debian systemctl start lighttpd.serviceFreeBSD echo ‘lighttpd_enable=YES’ >> /etc/rc.conf && /usr/local/etc/rc.d/lighttpd start

Verifica che lighttpd stia ascoltando sulla porta TCP 80

netstat -anp|grep lighttpdtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3893/lighttpd

CAntonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 20: Internet e architetture di rete la ragazza della porta ottanta: HTTP

telnet localhost 80Trying 127.0.0.1...Connected to localhost.Escape character is '^]'.GET / HTTP/1.1Host: localhost

Telnet LABHTTP/1.1 200 OKVary: Accept-EncodingContent-Type: text/htmlAccept-Ranges: bytesETag: "3446712510"Last-Modified: Sat, 28 May 2016 03:39:13 GMTContent-Length: 3568Date: Sat, 28 May 2016 04:58:07 GMTServer: lighttpd/1.4.33

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 21: Internet e architetture di rete la ragazza della porta ottanta: HTTP

elinks http://localhost

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 22: Internet e architetture di rete la ragazza della porta ottanta: HTTP

100 Continue101 Switching Protocols102 Processing

200 OK201 Created202 Accepted203 Non-authoritative Information204 No Content205 Reset Content206 Partial Content207 Multi-Status208 Already Reported226 IM Used

300 Multiple Choices301 Moved Permanently302 Found303 See Other304 Not Modified305 Use Proxy307 Temporary Redirect308 Permanent Redirect

1yz Informational

2yz Success

3yz Redirection

HTTP, codici di stato: 1yz, 2yz, 3yz

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 23: Internet e architetture di rete la ragazza della porta ottanta: HTTP

400 Bad Request401 Unauthorized402 Payment Required403 Forbidden404 Not Found405 Method Not Allowed406 Not Acceptable407 Proxy Authentication Required408 Request Timeout409 Conflict410 Gone411 Length Required412 Precondition Failed413 Payload Too Large414 Request-URI Too Long415 Unsupported Media Type416 Requested Range Not Satisfiable417 Expectation Failed418 I'm a teapot421 Misdirected Request422 Unprocessable Entity423 Locked424 Failed Dependency

HTTP, codici di stato: 4yz426 Upgrade Required428 Precondition Required429 Too Many Requests431 Request Header Fields Too Large444 Connection Closed Without Response451 Unavailable For Legal Reasons499 Client Closed Request

4yz Client error

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 24: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP, codici di stato: 5yz

5yz Server error

500 Internal Server Error501 Not Implemented502 Bad Gateway503 Service Unavailable504 Gateway Timeout505 HTTP Version Not Supported506 Variant Also Negotiates507 Insufficient Storage508 Loop Detected510 Not Extended511 Network Authentication Required599 Network Connect Timeout Error

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 25: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP over TLS[RFC 2818]

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 26: Internet e architetture di rete la ragazza della porta ottanta: HTTP

TCP/UDP 443[Kipp_E_B_Hickman]

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 27: Internet e architetture di rete la ragazza della porta ottanta: HTTP

HTTP/1.1 200 OKDate: Sun, 29 May 2016 16:27:11 GMTServer: Apache/2.4.20 (FreeBSD) OpenSSL/1.0.1e-freebsd PHP/5.4.45X-Powered-By: PHP/5.4.45Last-Modified: Thu, 01 Jan 1970 00:00:00 GMTTransfer-Encoding: chunkedContent-Type: text/html

openssl s_client -connect as59715.net:443CONNECTED(00000003)depth=1 /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3verify error:num=20:unable to get local issuer certificateverify return:0---Certificate chain 0 s:/CN=as59715.net i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3 1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3 i:/O=Digital Signature Trust Co./CN=DST Root CA X3---[...]

GET / HTTP/1.1Host: as59715.net[CRLF]

Telnet LAB

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 28: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Hypertext Transfer Protocol Version 2 (HTTP/2)[RFC 7540]

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 29: Internet e architetture di rete la ragazza della porta ottanta: HTTP

RFC 7540HTTP/2 enables a more efficient use of network resources and a reduced perception of latency by introducing header field compression and allowing multiple concurrent exchanges on the same connection

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Page 30: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530

Verificare il supporto di HTTP/2https://tools.keycdn.com/http2-test

nghttp -vn https://www.prado.it|grep -A 4 NPN[ 0.068][NPN] server offers: * h2 * spdy/3.1 * http/1.1The negotiated protocol: h2

Page 31: Internet e architetture di rete la ragazza della porta ottanta: HTTP

Questions?Antonio Prado - Internet e architetture di rete - CentroGiovani San Benedetto del Tronto - 20160530