|
| 1 | +title: Web Servers |
| 2 | +category: page |
| 3 | +slug: web-servers |
| 4 | +sort-order: 04 |
| 5 | + |
| 6 | + |
| 7 | +# Web servers |
| 8 | +Web servers respond to |
| 9 | +[Hypertext Transfer Protocol](http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) (HTTP) |
| 10 | +requests from clients. A client is usually a browser such as Internet Explorer, |
| 11 | +Firefox, or Chrome, but it can also be a |
| 12 | + |
| 13 | +* headless browser, commonly use for testing, such as |
| 14 | + [phantomjs](http://phantomjs.org/) |
| 15 | +* commandline utility, for example [wget](https://www.gnu.org/software/wget/) |
| 16 | + and [curl](http://curl.haxx.se/) |
| 17 | +* text-based web browser such as |
| 18 | + [Lynx](http://lynx.browser.org/) |
| 19 | +* web crawler. |
| 20 | + |
| 21 | +Web server process requests from the above clients. The result of the web |
| 22 | +server's processing is a |
| 23 | +[response code](https://developer.mozilla.org/en-US/docs/HTTP/Response_codes) |
| 24 | +and commonly a content response. Some status codes, such as 204 (No content) |
| 25 | +and 403 (Forbidden), do not have content responses. |
| 26 | + |
| 27 | +In a simple case, the client will request a static asset such as a picture |
| 28 | +or JavaScript file. The file sits on the file system in a location the |
| 29 | +web server is authorized to access and the web server sends the file |
| 30 | +to the client with a 200 status code. If the client already requested the |
| 31 | +file and the file has not changed, the web server will pass back a 304 |
| 32 | +"Not modified" response indicating the client already has the latest version |
| 33 | +of that file. |
| 34 | + |
| 35 | +<img src="theme/img/web-browser-server-requests.png" width="100%" class="technical-diagram" alt="Web server and web browser request-response cycle" /> |
| 36 | + |
| 37 | +A web server sends files to a web browser based on the web browser's |
| 38 | +request. In the first request, the browser accessed the |
| 39 | +"www.fullstackpython.com" |
| 40 | +address and the server responded with the index.html HTML-formatted file. |
| 41 | +That HTML file contained references to other files, such as style.css and |
| 42 | +script.js that the browser then requested from the server. |
| 43 | + |
| 44 | +Sending static assets (such as CSS and JavaScript files) can eat up a |
| 45 | +large amount of bandwidth which is why using a Content Delivery Network |
| 46 | +(CDN) is important when possible (see the content delivery network |
| 47 | +section for a more detailed explanation). |
| 48 | + |
| 49 | + |
| 50 | +## Web Server Resources |
| 51 | +[How to set up a safe and secure Web server](http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/) |
| 52 | + |
| 53 | +[Apache and mod\_wsgi on Ubuntu 10.04](http://library.linode.com/web-servers/apache/mod-wsgi/ubuntu-10.04-lucid) |
| 54 | + |
| 55 | +[Nginx web server tutorials](http://articles.slicehost.com/nginx) |
| 56 | + |
| 57 | +[Nginx for Developers: An Introduction](http://carrot.is/coding/nginx_introduction) |
| 58 | + |
| 59 | +An example of an [Nginx security configuration](http://tautt.com/best-nginx-configuration-for-security/). |
| 60 | + |
| 61 | +A reference with the full list of |
| 62 | +[HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) |
| 63 | +is provided by W3C. |
| 64 | + |
| 65 | +An optimization guide for |
| 66 | +"[battle ready Nginx](http://blog.zachorr.com/nginx-setup/)." |
| 67 | + |
| 68 | +[A faster Web server: ripping out Apache for Nginx](http://arstechnica.com/business/2011/11/a-faster-web-server-ripping-out-apache-for-nginx/) |
| 69 | + |
| 70 | +[4 HTTP Security Headers You Should Always Be Using](http://ibuildings.nl/blog/2013/03/4-http-security-headers-you-should-always-be-using) |
0 commit comments