SlideShare a Scribd company logo
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 run
on any connection oriented protocol
● RFCs 2616, 5785, 6266, 6585, 3986, 6874
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
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-2600,2900-3200 + CRLF
CRLF
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 .....
HTTP proto differences
● HTTP/1.0
– close connection after each request
● HTTP/1.1
– Host header
– Connection: keep-alive
– CONNECT method
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
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
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
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 && desc_ready > 0; ++i) {
VS.
for (;;) {
nfds = epoll_wait(epollfd, events, MAX_EVENTS, -1);
Module structure - Startup
● Pre-Config
● Test Configuration
● Post Configuration
● Open Logs
● Child Init
– Note that all of these are performed at least two times!
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
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
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
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
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/

More Related Content

PDF
Apache Dispatch
PDF
PHP Development Tools
PDF
GopherCon IL 2020 - Web Application Profiling 101
PPTX
PHP 5.6 New and Deprecated Features
ODP
1. MySql plugins
PDF
OB1K - New, Better, Faster, Devops Friendly Java container by Outbrain
PPTX
Xdebug - Your first, last, and best option for troubleshooting PHP code
PPTX
Shall we play a game?
Apache Dispatch
PHP Development Tools
GopherCon IL 2020 - Web Application Profiling 101
PHP 5.6 New and Deprecated Features
1. MySql plugins
OB1K - New, Better, Faster, Devops Friendly Java container by Outbrain
Xdebug - Your first, last, and best option for troubleshooting PHP code
Shall we play a game?

What's hot (19)

PDF
Shall we play a game?
PPTX
Ob1k presentation at Java.IL
PDF
Profiling and optimizing go programs
ODP
Xmla4js
PDF
Gdb basics for my sql db as (percona live europe 2019)
PDF
Make Your Own Developement Board @ 2014.4.21 JuluOSDev
PDF
We shall play a game....
ODP
The why and how of moving to php 5.4
PDF
OSMC 2014: Monitoring VoIP Systems | Sebastian Damm
PPTX
20151229 wnmp & phalcon micro app - part I
PDF
[232]TensorRT를 활용한 딥러닝 Inference 최적화
PDF
[232] TensorRT를 활용한 딥러닝 Inference 최적화
PDF
The Simple Scheduler in Embedded System @ OSDC.TW 2014
PPTX
10 Most Important Features of New PHP 5.6
PDF
Golang Performance : microbenchmarks, profilers, and a war story
KEY
Lock? We don't need no stinkin' locks!
ODP
Snaps on open suse
PDF
NPF scripting with Lua by Lourival Vieira Neto
PDF
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Shall we play a game?
Ob1k presentation at Java.IL
Profiling and optimizing go programs
Xmla4js
Gdb basics for my sql db as (percona live europe 2019)
Make Your Own Developement Board @ 2014.4.21 JuluOSDev
We shall play a game....
The why and how of moving to php 5.4
OSMC 2014: Monitoring VoIP Systems | Sebastian Damm
20151229 wnmp & phalcon micro app - part I
[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화
The Simple Scheduler in Embedded System @ OSDC.TW 2014
10 Most Important Features of New PHP 5.6
Golang Performance : microbenchmarks, profilers, and a war story
Lock? We don't need no stinkin' locks!
Snaps on open suse
NPF scripting with Lua by Lourival Vieira Neto
Linux /proc filesystem for MySQL DBAs - FOSDEM 2021
Ad

Viewers also liked (20)

KEY
Using Apache as an Application Server
PPT
Apache Web Server Architecture Chaitanya Kulkarni
PDF
Autodiagnosis
PDF
Branwyn April 2013
PDF
1893 12
PDF
Yoga for Teeth, Ear, Nose, Throat and over all hygeine
PPT
Journey Through Babudom and Netaland
PDF
Autoabstract of the dissertation on topic: "Optimizing the use of financial ...
PDF
Grammaticus (Carolus Cabanillas auctor)
DOCX
educazione personalizzata Garcia Hoz
PPTX
PDF
02 diagenesis
PDF
Astrologie relationala
PPTX
Html5移动网站开发实践
PPTX
The axilla
PPT
Cyril (vijaynagar1.ppt)
PPT
Autotransfusion
PPT
Text Message Marketing for Barber shops
PPTX
Babyhood
Using Apache as an Application Server
Apache Web Server Architecture Chaitanya Kulkarni
Autodiagnosis
Branwyn April 2013
1893 12
Yoga for Teeth, Ear, Nose, Throat and over all hygeine
Journey Through Babudom and Netaland
Autoabstract of the dissertation on topic: "Optimizing the use of financial ...
Grammaticus (Carolus Cabanillas auctor)
educazione personalizzata Garcia Hoz
02 diagenesis
Astrologie relationala
Html5移动网站开发实践
The axilla
Cyril (vijaynagar1.ppt)
Autotransfusion
Text Message Marketing for Barber shops
Babyhood
Ad

Similar to LSA2 - 03 Http apache nginx (20)

PDF
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
ODP
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
PDF
Nginx pres
PDF
03_clere-HTTP2 HTTP3 the State of the Art in Our Servers.pdf
PDF
Apache httpd reverse proxy and Tomcat
PDF
HTTP/3 where are we now? State of the art in our servers.
ODP
IT Operations for Web Developers
PDF
Php 5.6 From the Inside Out
ODP
Random tips that will save your project's life
PDF
Apache2 BootCamp : Serving Dynamic Content with CGI
PDF
NodeJS
PPT
Securing Your Webserver By Pradeep Sharma
PDF
.NET @ apache.org
PDF
Joomla Code Quality Control and Automation Testing
PDF
(phpconftw2012) PHP as a Middleware in Embedded Systems
PDF
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
PDF
"Swoole: double troubles in c", Alexandr Vronskiy
PPT
Nginx internals
PDF
NS3 Overview
PDF
Automating Complex Setups with Puppet
PLNOG 4: Leszek Urbański - A modern HTTP accelerator for content providers
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nginx pres
03_clere-HTTP2 HTTP3 the State of the Art in Our Servers.pdf
Apache httpd reverse proxy and Tomcat
HTTP/3 where are we now? State of the art in our servers.
IT Operations for Web Developers
Php 5.6 From the Inside Out
Random tips that will save your project's life
Apache2 BootCamp : Serving Dynamic Content with CGI
NodeJS
Securing Your Webserver By Pradeep Sharma
.NET @ apache.org
Joomla Code Quality Control and Automation Testing
(phpconftw2012) PHP as a Middleware in Embedded Systems
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
"Swoole: double troubles in c", Alexandr Vronskiy
Nginx internals
NS3 Overview
Automating Complex Setups with Puppet

More from Marian Marinov (20)

PDF
How to start and then move forward in IT
PDF
Thinking about highly-available systems and their setup
PDF
Understanding your memory usage under Linux
PDF
How to implement PassKeys in your application
PDF
Dev.bg DevOps March 2024 Monitoring & Logging
PDF
Basic presentation of cryptography mechanisms
PDF
Microservices: Benefits, drawbacks and are they for me?
PDF
Introduction and replication to DragonflyDB
PDF
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
PDF
How to successfully migrate to DevOps .pdf
PDF
How to survive in the work from home era
PDF
Managing sysadmins
PDF
Improve your storage with bcachefs
PDF
Control your service resources with systemd
PDF
Comparison of-foss-distributed-storage
PDF
Защо и как да обогатяваме знанията си?
PDF
Securing your MySQL server
PDF
Sysadmin vs. dev ops
PDF
DoS and DDoS mitigations with eBPF, XDP and DPDK
PDF
Challenges with high density networks
How to start and then move forward in IT
Thinking about highly-available systems and their setup
Understanding your memory usage under Linux
How to implement PassKeys in your application
Dev.bg DevOps March 2024 Monitoring & Logging
Basic presentation of cryptography mechanisms
Microservices: Benefits, drawbacks and are they for me?
Introduction and replication to DragonflyDB
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
How to successfully migrate to DevOps .pdf
How to survive in the work from home era
Managing sysadmins
Improve your storage with bcachefs
Control your service resources with systemd
Comparison of-foss-distributed-storage
Защо и как да обогатяваме знанията си?
Securing your MySQL server
Sysadmin vs. dev ops
DoS and DDoS mitigations with eBPF, XDP and DPDK
Challenges with high density networks

Recently uploaded (20)

PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Types and Its function , kingdom of life
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
01-Introduction-to-Information-Management.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Business Ethics Teaching Materials for college
PDF
Classroom Observation Tools for Teachers
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Basic Mud Logging Guide for educational purpose
Cell Types and Its function , kingdom of life
Anesthesia in Laparoscopic Surgery in India
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
O7-L3 Supply Chain Operations - ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Final Presentation General Medicine 03-08-2024.pptx
Microbial disease of the cardiovascular and lymphatic systems
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
TR - Agricultural Crops Production NC III.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
01-Introduction-to-Information-Management.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Business Ethics Teaching Materials for college
Classroom Observation Tools for Teachers
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Week 4 Term 3 Study Techniques revisited.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF

LSA2 - 03 Http apache nginx

  • 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/