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
6
690
nginx
Quick introduction of nginx and the configs that a developer can use on a day by day base
Bert Pattyn
April 12, 2012
Tweet
Share
Other Decks in Technology
See All in Technology
品質視点から考える組織デザイン/Organizational Design from Quality
mii3king
0
210
Unlocking the Power of AI Agents with LINE Bot MCP Server
linedevth
0
110
Apache Spark もくもく会
taka_aki
0
130
20250913_JAWS_sysad_kobe
takuyay0ne
2
250
Firestore → Spanner 移行 を成功させた段階的移行プロセス
athug
1
500
エンジニアリングマネージャーの成長の道筋とキャリア / Developers Summit 2025 KANSAI
daiksy
3
830
5分でカオスエンジニアリングを分かった気になろう
pandayumi
0
260
AIのグローバルトレンド2025 #scrummikawa / global ai trend
kyonmm
PRO
1
310
なぜテストマネージャの視点が 必要なのか? 〜 一歩先へ進むために 〜
moritamasami
0
240
Create Ruby native extension gem with Go
sue445
0
120
開発者を支える Internal Developer Portal のイマとコレカラ / To-day and To-morrow of Internal Developer Portals: Supporting Developers
aoto
PRO
1
480
TS-S205_昨年対比2倍以上の機能追加を実現するデータ基盤プロジェクトでのAI活用について
kaz3284
1
210
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.6k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.8k
A Modern Web Designer's Workflow
chriscoyier
696
190k
How to train your dragon (web standard)
notwaldorf
96
6.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Unsuck your backbone
ammeep
671
58k
Done Done
chrislema
185
16k
Visualization
eitanlees
148
16k
Large-scale JavaScript Application Architecture
addyosmani
513
110k
Designing Experiences People Love
moore
142
24k
Into the Great Unknown - MozCon
thekraken
40
2k
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