Your SlideShare is downloading. ×
0
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
LSA2 - 03 Http apache nginx
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

LSA2 - 03 Http apache nginx

2,109

Published on

Linux System Administration 2 - HTTP, Apache, Nginx

Linux System Administration 2 - HTTP, Apache, Nginx

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,109
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. WEB? HTTPHTTP ApacheApache NginxNginx
  • 2. HTTP ● Text based protocl defined in 1991 ● V0.9 defined default port 80 ● uses TCP/IP connection but should be able to run on any connection oriented protocol ● RFCs 2616, 5785, 6266, 6585, 3986, 6874
  • 3. HTTP vs. Gopher ● HTTP defines HTML as formatting for documents ● Gopher defines menu style format ● HTTP does not define any easy for searching and indexing pages ● Trough its simple structure, gopher allows easy search and indexing ● HTTP 80rfc2616 Gopher 70rfc1436 ● Gopher defined the URI standard
  • 4. HTTP – Methods – Requests – Responses – Headers – URI/URL – CGI
  • 5. HTTP Methods Method URI Proto GET /lib/ana/sex.txt HTTP/1.0 ● GET ● HEAD ● POST ● OPTIONS ● TRACE ● PUT ● DELETE
  • 6. HTTP Requests Method URI Proto + CRLF HEADER + CRLF HEADER + CRLF CRLF GET /pics/ana/naked.jpg HTTP/1.0 + CRLF Range: 2400-2600,2900-3200 + CRLF CRLF
  • 7. HTTP Responses GET /pics/ana/naked.jpg HTTP/1.0 + CRLF Range: 2400-2600,2900-3200 + CRLF CRLF Proto Status Reason HTTP/1.0 200 OK + CRLF Response headers + CRLF CRLF .... binary data here .....
  • 8. HTTP proto differences ● HTTP/1.0 – close connection after each request ● HTTP/1.1 – Host header – Connection: keep-alive – CONNECT method
  • 9. Uniform Resource Identifier (URI) ● UR Locator - URL ● Protocols: file, http, https, ftp, ftps, mailto, telnet, ssh, smb, irc proto :// user:pass @ host : port / path ? params params: param=value & param=value
  • 10. Common Gateway Interface (CGI) ● CGI is not Computer Generated Imagery :) Web Server Dynamic Content Generator (CGI script) SERVER_SOFTWARE SERVER_NAME GATEWAY_INTERFACESERVER_PROTOCOL SERVER_PORT REQUEST_METHOD PATH_INFO - request path PATH_TRANSLATED - full fs path SCRIPT_NAME - request path QUERY_STRING REMOTE_HOST REMOTE_ADDR AUTH_TYPE REMOTE_USER REMOTE_IDENT CONTENT_TYPE CONTENT_LENGTH
  • 11. Common Gateway Interface (CGI) ● CGI is not Computer Generated Imagery :) Web Server Dynamic Content Generator (CGI script) /bin/sh + special environment variables 1. Create a new environment 2. Create a new shell process 3. Execute the script Note: the script must be executable and must be able to produce the required output. Responses must start with: Content-type: some-type + CRLF Responses may include Status codes: 200 OK + CRLF
  • 12. Apache ● Documentation ● Module architecture ● Multi-processing Modules (MPMs) ● Additional Modules
  • 13. MPMs - Prefork ● mpm_common ● Prefork ● Worker ● Event Child Child Child Memory Memory Memory Memory Main Process
  • 14. MPMs - Worker ● mpm_common ● Prefork ● Worker ● Event Child Child Child Main Process Memory
  • 15. MPMs - event ● mpm_common ● Prefork ● Worker ● Event desc_ready = select(1, &rfds, NULL, NULL, &tv); for (i=0; i <= max_fd && desc_ready > 0; ++i) { VS. for (;;) { nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);
  • 16. Module structure - Startup ● Pre-Config ● Test Configuration ● Post Configuration ● Open Logs ● Child Init – Note that all of these are performed at least two times!
  • 17. Module structure - Request ● Pre-Connection ● Create Connection ● Process Connection ● Create Request ● Post-Read Request ● Header Parse ● HTTP Scheme ● Default Port ● Quick Handler ● Translate Name ● Map to Storage ● Check Access ● Verify User ID ● Verify User Access ● Check Type ● Fixups ● Insert Filters ● Content Handlers ● Logging ● Insert Errors
  • 18. Apache - Content handlers module_name module_file mime_type priority cgi_module mod_cgi.c .cgi .pl .sh 10 php_module mod_php.c .php .php5 10 perl_module mod_perl.c .pl .pm 10
  • 19. Apache - CGI execution Apache Child mod_php Child mod_cgi root nobody nobody Child mod_cgi Child mod_suphp index.php index.php suexec index.php /bin/sh /bin/sh suphp index.php/bin/sh user user
  • 20. Apache - CGI execution Apache Child mod_fcgid Child mod_fcgid root nobody user index.php FastCGI daemon child child child index.php index.php suexec
  • 21. Apache structure ● bin/ – httpd - the server – ab - Apache Bench – apxs - externel module builder – htpasswd – suexec ● conf/ – httpd.conf – mime.typs + magic ● modules/ (libexec on 1.3) ● logs/

×