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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Bert Pattyn
April 12, 2012
Technology
690
6
Share
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
続 運用改善、不都合な真実 〜 物理制約のない運用改善はほとんど無価値 / 20260518-ssmjp-kaizen-no-value-without-physical-constraints
opelab
2
320
Kaggle未経験社員をメダリストに育てる「AIドラゴン桜」
lycorptech_jp
PRO
0
160
Claude Code x Accounting
kawaguti
PRO
0
280
TSKaigi 2026 - 10秒のビルドを1秒へ:tsdownが切り拓く2026年のTypeScriptライブラリ開発
teamlab
PRO
1
130
自作エディターをOSSにして分かった、一人に刺さる開発が世界を動かす理由
shinyasaita
1
260
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4.5k
権限管理設計を完全に理解した
rsugi
1
150
React Compiler導入の効果と運用の工夫
kakehashi
PRO
3
320
Cortex(Code) を ML モデルの 精度改善サイクルに組み込む.pdf
oimo23
0
260
はじめてのAI-DLC
yoshidashingo
2
410
AIAgentと取り組むKaggle
508shuto
2
500
ルール・ロール・ツールを創る / Creating Rules, Roles and Tools
ks91
PRO
0
150
Featured
See All Featured
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
280
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
Fireside Chat
paigeccino
42
3.9k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
260
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
120
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.6k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Site-Speed That Sticks
csswizardry
13
1.2k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
210
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
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