Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
nginx
Search
Bert Pattyn
April 12, 2012
Technology
700
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
nginx
Quick introduction of nginx and the configs that a developer can use on a day by day base
Bert Pattyn
April 12, 2012
Other Decks in Technology
See All in Technology
AIで政治は変わるのか? — 中高生と考えたAI時代の民主主義(東海高校サタデープログラム)
eitarosuda
0
410
勉強会企画をアプリで構造化してみた 〜そこで見えた、AIとの付き合い方〜 / I've structured a study group plan using an app.
pauli
0
340
Control Planeで育てるBtoB SaaSの認証基盤 - SRE NEXT 2026
pokohide
1
2k
SRE Lounge Hiroshimaへの招待
grimoh
0
560
Docker Desktop不要の時代が来る? WSL標準の「wslc」で Linuxコンテナを動かしてみた.
ueponx
0
860
DatabricksにおけるMCPソリューション
taka_aki
1
120
次世代ランサムウェア対策の考察 / 20260704 Mitsutoshi Matsuo
shift_evolve
PRO
5
1.7k
AWS Summit の片隅で、体育座りしながらコミュニティがにぎわう理由を考えた
k_adachi_01
2
370
ADDF - ループエンジニアリングするフレームワークを作ったら/I Didn't Set Out to Build Loop Engineering, But ADDF Did
fruitriin
0
100
Foxgloveについて 実際にExtensionを開発して公開するまでの話 / About Foxglove: The Story of Developing and Releasing an Extension
ry0_ka
0
190
Baseline対応のDOMの型定義を作った
uhyo
3
730
SREとQA 二人三脚で進めるSLO運用/sre-qa-slo
sugitak
0
150
Featured
See All Featured
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
190
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
460
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Marketing to machines
jonoalderson
1
5.6k
WENDY [Excerpt]
tessaabrams
11
38k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Automating Front-end Workflow
addyosmani
1370
210k
Being A Developer After 40
akosma
91
590k
Writing Fast Ruby
sferik
630
63k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
The Limits of Empathy - UXLibs8
cassininazir
1
410
Transcript
None
Hi! I'm Bert.
nginx From russia with love
nginx is a combined webserver and a reverse proxy.
Why nginx? • event based -> more connections, less overhead
• efficiency • smaller memory footprint • friendly configuration format
Problems? • No support for .htaccess files • less documentation
(but enough!), growing very fast
Modules • core modules: core, events • standard http modules
• optional http modules Overview: http://wiki.nginx.org/Modules
Main configuration file /etc/nginx/nginx.conf
error_log /var/log/nginx/error.log; http { access_log /var/log/nginx/access.log; }
http { gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; }
http { include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
Default server block configuration file /etc/nginx/sites-available/default
server { listen 80; server_name www.example.be; server_name_in_redirect off; root /home/sites/default_www;
client_max_body_size 64M; }
server_name 1. full, static names www.example.be 2. names with a
wildcard at the start *.example.be 3. names with a wildcard at the end www.example.* 4. names with regex ~^www\d+\.example\.be$ 5. wildcard _
server { listen 80; server_name www.example.be; server_name_in_redirect off; root /home/sites/default_www;
client_max_body_size 64M; }
server { listen 80; server_name www.example.be; server_name_in_redirect off; root /home/sites/default_www;
client_max_body_size 64M; }
server { location ~ ^(.+\.php)(.*)$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php; } }
server { location / { if (!-e $request_filename) { rewrite
^(.*)$ /index.php last; } } }
rewrites.
server { listen 80 default; server_name _ example.be; rewrite ^(.*)
http://www.example.be$1 permanent; } server { server_name www.example.be }
server { listen 80; server_name www.example.be; rewrite ^/routebeschrijving /nl/praktisch/ routebeschrijving-and-parkeren
permanent; rewrite ^/media/(.*)$ /mp3/$1.mp3 last; rewrite_log on; }
flags 1. last (stop processing, restart search for location blocks)
2. break (stop rewrite processing, continue non-rewrite processing in current location block) 3. redirect (302) 4. permanent (301)
gzip.
server { gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_comp_level 6; gzip_types
text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js ; }
caching.
server { location ~ \.(css|js)$ { expires 31d; add_header Pragma
"public"; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; } }
access.
server { location / { allow 10.1.1.0/16; deny all; }
}
test and activate changes sudo /etc/init.d/nginx reload
Other modules • Auth Basic - Basic HTTP authentication •
Browser - Interpret "User-Agent" string • SSL - HTTPS/SSL support • ...
server { valid_referers none blocked www.example.be example.be; if($invalid_referer) { return
403; } if($http_cookie ~* "id=([^;] +)(?;;|$)") { set $id $1; } if ($http_user_agent ~ MSIE) { rewrite ^(.*)$ /msie/$1 break; }
Questions?
[email protected]
bertpattyn.iswijs.be