WEB?
HTTPHTTP
ApacheApache
NginxNginx
HTTP
● Text based protocl defined in 1991
● V0.9 defined default port 80
● uses TCP/IP connection but should be able to ru...
HTTP vs. Gopher
● HTTP defines HTML as formatting for documents
● Gopher defines menu style format
● HTTP does not define ...
HTTP
– Methods
– Requests
– Responses
– Headers
– URI/URL
– CGI
HTTP Methods
Method URI Proto
GET /lib/ana/sex.txt HTTP/1.0
● GET
● HEAD
● POST
● OPTIONS
● TRACE
● PUT
● DELETE
HTTP Requests
Method URI Proto + CRLF
HEADER + CRLF
HEADER + CRLF
CRLF
GET /pics/ana/naked.jpg HTTP/1.0 + CRLF
Range: 2400...
HTTP Responses
GET /pics/ana/naked.jpg HTTP/1.0 + CRLF
Range: 2400-2600,2900-3200 + CRLF
CRLF
Proto Status Reason
HTTP/1.0...
HTTP proto differences
● HTTP/1.0
– close connection after each request
● HTTP/1.1
– Host header
– Connection: keep-alive
...
Uniform Resource Identifier
(URI)
● UR Locator - URL
● Protocols: file, http, https, ftp, ftps, mailto, telnet,
ssh, smb, ...
Common Gateway Interface
(CGI)
● CGI is not Computer Generated Imagery :)
Web Server
Dynamic Content Generator
(CGI script...
Common Gateway Interface
(CGI)
● CGI is not Computer Generated Imagery :)
Web Server
Dynamic Content Generator
(CGI script...
Apache
● Documentation
● Module architecture
● Multi-processing Modules (MPMs)
● Additional Modules
MPMs - Prefork
● mpm_common
● Prefork
● Worker
● Event
Child
Child
Child
Memory
Memory
Memory
Memory
Main
Process
MPMs - Worker
● mpm_common
● Prefork
● Worker
● Event
Child
Child
Child
Main Process
Memory
MPMs - event
● mpm_common
● Prefork
● Worker
● Event
desc_ready = select(1, &rfds, NULL, NULL, &tv);
for (i=0; i <= max_fd...
Module structure - Startup
● Pre-Config
● Test Configuration
● Post Configuration
● Open Logs
● Child Init
– Note that all...
Module structure - Request
● Pre-Connection
● Create Connection
● Process Connection
● Create Request
● Post-Read Request
...
Apache - Content handlers
module_name module_file mime_type priority
cgi_module mod_cgi.c .cgi .pl .sh 10
php_module mod_p...
Apache - CGI execution
Apache
Child mod_php
Child mod_cgi
root
nobody
nobody
Child mod_cgi
Child mod_suphp
index.php
index...
Apache - CGI execution
Apache
Child mod_fcgid
Child mod_fcgid
root
nobody
user
index.php
FastCGI
daemon
child
child
child
...
Apache structure
● bin/
– httpd - the server
– ab - Apache Bench
– apxs - externel module builder
– htpasswd
– suexec
● co...
Upcoming SlideShare
Loading in...5
×

LSA2 - 03 Http apache nginx

2,151

Published on

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,151
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

LSA2 - 03 Http apache nginx

  1. 1. WEB? HTTPHTTP ApacheApache NginxNginx
  2. 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. 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. 4. HTTP – Methods – Requests – Responses – Headers – URI/URL – CGI
  5. 5. HTTP Methods Method URI Proto GET /lib/ana/sex.txt HTTP/1.0 ● GET ● HEAD ● POST ● OPTIONS ● TRACE ● PUT ● DELETE
  6. 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. 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. 8. HTTP proto differences ● HTTP/1.0 – close connection after each request ● HTTP/1.1 – Host header – Connection: keep-alive – CONNECT method
  9. 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. 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. 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. 12. Apache ● Documentation ● Module architecture ● Multi-processing Modules (MPMs) ● Additional Modules
  13. 13. MPMs - Prefork ● mpm_common ● Prefork ● Worker ● Event Child Child Child Memory Memory Memory Memory Main Process
  14. 14. MPMs - Worker ● mpm_common ● Prefork ● Worker ● Event Child Child Child Main Process Memory
  15. 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. 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. 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. 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. 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. 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. 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/
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×