1 / 57

Basic Web Server Operation

Basic Web Server Operation. Dr C. P. Jobling (C.P.Jobling@Swansea.ac.uk). Part 3: Server-Side Programming. Basic Web Server Operation Interactive Services The Ruby Programming Language Ruby on Rails RESTful Web Services Datastorage and the Cloud. Basic Web Server Operation.

hue
Download Presentation

Basic Web Server Operation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic Web Server Operation Dr C. P. Jobling (C.P.Jobling@Swansea.ac.uk)

  2. Part 3: Server-Side Programming • Basic Web Server Operation • Interactive Services • The Ruby Programming Language • Ruby on Rails • RESTful Web Services • Datastorage and the Cloud

  3. Basic Web Server Operation • The roles of a web server and web client • Modern Web Servers • The Apache Web Server • Revision of the Hypertext Transfer Protocol • Web server operation • Mapping resources to files

  4. The Role of a Web Server A web server has only one role respond to a client request.

  5. Client Request The web server takes a client request and gives something back to the client. • Browserrequests a resource. • Serverreceives the request • Server finds the resource (or not) • Server returns somethingto the client.

  6. A resourcecan be • an HTML page • A CSS file • A JavaScript • A PDF file • A picture • A fragment of XML • A sound or video file • Some JSON data • ….

  7. Server Response Theresponseis formatted as a header, with success code and other information, followed by the resource data. • A content-type field in the header informs the client how the resource data is to be interpreted. • If the resource is not found, server issues a “404 not found” response.

  8. The Role of a Web Client • The web client is more “intelligent” than the web server • The web client (browser) lets the user request something from the server and shows the result of the request. • The client, by means of JavaScript, is capable of additional manipulation of resource data independently of the server.

  9. The “Brains” of the Operation Talks net protocols Ubiquitous Structured Stylish Programmable Interacts with humans Image Source: BBC: http://bbc.in/YcpNAE

  10. Basic Web Server Operation • The roles of a web server and web client • Modern Web Servers • The Apache Web Server • Revision of the Hypertext Transfer Protocol (HTTP) • Web server operation • Mapping resources to files

  11. Modern Web Servers Server Share Statistics (August 1995 to March 2013) Source: http://news.netcraft.com/

  12. Some Important Web Servers Apache Web Server (more later)

  13. Microsoft Internet Information Service (IIS) • Standard on windows professional • Windows only • Standard web services (files and CGI) • ASP technology provides server scripting in multiple languages • FrontPage server extensions • Key component of .NET

  14. Apache Tomcat • A web server written in Java • Runs on any platform that supports Java • Standard web services (files and CGI) • A “servlet container” which uses Java as a web application programming language and Java Server Pages (JSP) for interactivity. • Key component of J2EE.

  15. NGINX • A webserver that is designed to handle large numbers of simultaneous requests • Uses an event driven architecture rather than spawning a new thread per connection. • Allows popular websites to cope with large loads with predictable memory requirements. • Powers Wordpress,com, github.com, sourceforge etc. • More at: http://wiki.nginx.org/Main

  16. Basic Web Server Operation • The roles of a web server and web client • Modern Web Servers • The Apache Web Server • Revision of the HyperText Transfer Protocol (HTTP) • Web server operation • Mapping resources to files

  17. Apache Web Server (history) The very first web server was built by Tim Berners-Lee at CERN circa 1989

  18. Apache Web Server (history) First really popular web server was developed by NCSA and was available to all

  19. Apache Web Server (history) Apache was originally developed as a bug-fixed (“patched”) version of the NCSA Web Server version 1.3 First release 1995

  20. Apache Web Server (history) Apache is open source and is developed and maintained by a group of volunteers

  21. Apache Web Server (history) Apache is the most popular web server in use today (55% of the market, 102 Million active sites) Program called httpd and runs on most common platforms Latest version 2.24

  22. Some features of Apache Efficient: efficient at serving files, low impact on host.

  23. Some features of Apache Easy to set up for basic web services: files, SSI and CGI • Just put files into “document root” or “cgi-bin” and they are “on the web”

  24. Some features of Apache Extensible and modular: base services extensible by use of modules, e.g. • For authentication • For authorization • For session management • For logging • “In memory” server scripting: mod_perl, mod_python, PHP, FrontPage server extensions, … even ASP!.

  25. Some features of Apache Flexible- not just a web server • can be a proxy server • web cache • enables virtual hosting, etc

  26. Some features of Apache Installed on the EG-259 Virtual Machine

  27. Basic Web Server Operation • The roles of a web server and web client • Modern Web Servers • Introducing the Apache Web Server • Revision of the HyperText Transfer Protocol (HTTP) • Web server operation • Mapping resources to files

  28. request line (GET, POST, HEAD commands) header lines Carriage return, line feed indicates end of message HTTP request message • Two types of HTTP messages: request, response • HTTP request message: • ASCII (human-readable format) GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr (extra carriage return, line feed)

  29. HTTP messages Only two types of HTTP messages: • HTTP request • HTTP response

  30. request line (GET, POST, HEAD commands) header lines Carriage return, line feed indicates end of message HTTP Request HTTP request message: • ASCII (human-readable format) GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr (extra carriage return, line feed)

  31. status line (protocol status code status phrase) header lines data, e.g., requested HTML file HTTP response message HTTP/1.1 200 OK Connection close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

  32. HTTP response status codes In first line in server->client response message. Some examples: 200 OK request succeeded, requested object later in this message 301 Moved Permanently requested object moved, new location specified later in this message (Location:) 400 Bad Request request message not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported

  33. Protocol version URI More about Host later request line (GET, POST, HEAD commands) Client information header lines Content negotiation Carriage return, line feed indicates end of message HTTP request message GET /products/ HTTP/1.1 Host: mycompany.com User-agent: Mozilla/4.0 : Accept-language:fr (extra carriage return, line feed)

  34. status line (protocol status code status phrase) header lines Server information data, e.g., requested HTML file Helps browser To cache data Describes data: helps browser to render data Size of content in bytes HTTP response message HTTP/1.1 200 OK : Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

  35. Some Important Definitions URI (uniform resource identifier) • Format <protocol>://<host>/<resource> • Uniquely identifies a resource on the Internet • Example: http://mycompany.com/products/

  36. Some Important Definitions Resource Identifier (RI) • Uniquely identifies a resource on a host • Maps either to a file or to a program • Example: /products/

  37. Some Important Definitions Content-Type • Identifies the type of data contained in a response • Used by the browser to render the data content of a response • Uses MIME standard specifications • Examples: text/html,image/jpeg, application/pdf.

  38. Some Important Definitions Host • Identifies host to which request is directed. Allows many web hosts to exist at a single IP address.

  39. Basic Web Server Operation • The roles of a web server and web client • Modern Web Servers • The Apache Web Server • Revision of the HyperText Transfer Protocol (HTTP) • Web server operation • Mapping resources to files

  40. browser <html> <html> <html> user files server Web Server Operation User types URL into browser orclicks on a hyperlink. E.g.http://mycompany.com/products/

  41. browser <html> <html> <html> user files server Web Server Operation • Browser opens a TCP connection to server • requires DNS query to map hostnameto IP address. • three-way handshake with web server process listening on port 80

  42. browser <html> <html> <html> user files server Web Server Operation GET /products/ HTTP/1.1Host: mycompany.com • Browser creates and sends GET request • actually sent with final acknowledgementthat establishes the TCP connection

  43. browser <html> <html> <html> user files server index.html <html> Web Server Operation GET /products/ HTTP/1.1Host: mycompany.com • Server interprets GET request • Host field used to identify virtual host • URI /products/ identifies resource • index.html in directory identified by/products

  44. browser <html> <html> <html> user files server index.html <html> Web Server Operation HTTP/1.1 200 OK:Content-Type: text/html • Server creates a response message • response code + content-type • Resource added to response

  45. browser <html> <html> <html> user files server HTTP/1.1 200 OK:Content-Type: text/html index.html <html> Web Server Operation Server returns response to client

  46. browser <html> <html> <html> user files server HTTP/1.1 200 OK:Content-Type: text/html index.html <html> Web Server Operation GET … HTTP 1.1 200 OKContent-type: image/jpeg • Browser parses response • Notes that content-type is HTML • Renders HTML in browser… • Makes further requests for embedded objects

  47. browser <html> <html> <html> user files server Web Server Operation HTTP/1.1 404 Not found Web server returns a response even if it cannot satisfy the request.

  48. browser <html> <html> <html> user files server Web Server Operation When page is rendered browser closes TCP connection

  49. browser <html> <html> <html> user files server Web Server Operation Server waits for next request

  50. Basic Web Server Operation • The roles of a web server and web client • Modern Web Servers • Introducing the Apache Web Server • Revision of the HyperText Transfer Protocol (HTTP) • Web server operation • Mapping resources to files

More Related