SlideShare a Scribd company logo
Nginx
Introduction
Nginx
Nginx (pronounced "engine-x") is an open source reverse proxy server for
HTTP(S), SMTP, POP3, and IMAP protocols, as well as a load balancer,
HTTP cache, and a web server (origin server).
Installation
Installation on Ubuntu
sudo -s
nginx=stable # use nginx=development for latest development version
echo "deb http://ppa.launchpad.net/nginx/$nginx/ubuntu lucid main" > /etc/apt/sources.list.
d/nginx-$nginx-lucid.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C
apt-get update
apt-get install nginx
Configuration
● /etc/nginx
● /etc/nginx/nginx.conf # global config
worker_processes 4; # = CPU Number
worker_connections 65535; # max connections per process
gzip on; # enable gzip
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml
application/xml+rss text/javascript;
Configuration
● /etc/init.d/nginx {start | stop | reload | restart }
● /var/log/nginx # log
● /etc/nginx/sites-available # Virtual Host Configs, 保存配置的地方
● /etc/nginx/sites-enabled # 要enable的配置保存的地方
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
Configuration
server {
listen 80; ## binding port
server_name tiger.prod.kalengo.cn; ## domain
access_log /var/log/nginx/onepiece_access.log;
error_log /var/log/nginx/onepiece_error.log;
root /var/www; ## website root directory
location / {
......
}
location /xxx {
…...
}
location /xxx/yyy {
…...
}
location ~* .*.(css|js)$ {
add_header Cache-Control max-age=3600;
}
location ~ .php$ { ## pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
Configuration
location /files {
add_header Cache-Control max-age=259200;
alias /var/www/public/files;
autoindex off;
}
location /journal {
add_header Cache-Control max-age=3600;
alias /var/www/public/files/journal;
autoindex off;
}
location ~ ^/images/(w+?).jpg_(d+)x(d+) {
add_header Cache-Control max-age=259200;
alias /var/www/public/files/images/$2x/$1.jpg;
autoindex off;
}
P.S: location 匹配顺序 ≠ 文件编辑顺序
Upgrade on the Fly
1. ./configure & make
a. nginx -V
2. backup & replace
a. mv nginx nginx.old
b. cp objs/nginx nginx
3. start & quit
a. kill -USR2
b. kill -QUIT
p.s:
1. Nginx平滑升级
2. Nginx Upgrade
Resource
Beginner’s Guide
Admin’s Guide
How nginx processes a request

More Related Content

ODT
Squid file
PPT
Squid Server
PDF
PDF
Rdo mitaka
PPT
论文答辩
PDF
Unidade3 roteiro proxy
PDF
Squid proxy-configuration-guide
PPT
Linux Server Start
Squid file
Squid Server
Rdo mitaka
论文答辩
Unidade3 roteiro proxy
Squid proxy-configuration-guide
Linux Server Start

What's hot (20)

PPT
Squid server
PDF
FreeBSD, ipfw and OpenVPN 2.1 server
DOCX
Install elasticsearch, logstash and kibana
PPT
How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
PDF
Step by-step installation of a secure linux web dns- and mail server
ODP
Squid Proxy Server
DOCX
Project on squid proxy in rhel 6
PPTX
NGINX: Basics & Best Practices - EMEA Broadcast
PDF
Helpful pre commit hooks for Python and Django
PDF
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
PDF
Стажировка 2015. Разработка. Занятие 5. Использование nginx
PPTX
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
PDF
Pound & Varnish - Cache e Balanceamento de Carga
DOCX
Kickstart server
PPT
Squid Caching for Web Content Accerlation
DOCX
PDF
Micro Datacenter & Data Warehouse
PDF
A little waf
PDF
Docker Setting for Static IP allocation
PDF
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
Squid server
FreeBSD, ipfw and OpenVPN 2.1 server
Install elasticsearch, logstash and kibana
How To Deploy A Cloud Based Webserver in 5 minutes - LAMP
Step by-step installation of a secure linux web dns- and mail server
Squid Proxy Server
Project on squid proxy in rhel 6
NGINX: Basics & Best Practices - EMEA Broadcast
Helpful pre commit hooks for Python and Django
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Стажировка 2015. Разработка. Занятие 5. Использование nginx
Quick Start Guide using Virtuozzo 7 (β) on AWS EC2
Pound & Varnish - Cache e Balanceamento de Carga
Kickstart server
Squid Caching for Web Content Accerlation
Micro Datacenter & Data Warehouse
A little waf
Docker Setting for Static IP allocation
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
Ad

Similar to Nginx (20)

PDF
NGINX ADC: Basics and Best Practices
PDF
NGINX ADC: Basics and Best Practices – EMEA
PDF
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
PDF
NGINX: Basics and Best Practices EMEA
PDF
How to Get Started With NGINX
PPTX
NGINX 101 - now with more Docker
PPTX
NGINX 101 - now with more Docker
ODP
Introduction to Nginx
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
PPTX
NGINX: Basics and Best Practices
PDF
Install nginx on ubuntu 21.04 server
PPTX
NGINX: Back to Basics – APCJ
PPTX
NGINX Installation and Tuning
PPTX
Nginx-deploy on linux server with 80 and 442
PDF
NginX - good practices, tips and advanced techniques
PDF
Deploying nginx with minimal system resources
PDF
Nginx Scripting - Extending Nginx Functionalities with Lua
PDF
Devinsampa nginx-scripting
PDF
Nginx常见应用技术指南(Nginx Tips)
PPTX
Load Balancing Container with Nginx
NGINX ADC: Basics and Best Practices
NGINX ADC: Basics and Best Practices – EMEA
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
NGINX: Basics and Best Practices EMEA
How to Get Started With NGINX
NGINX 101 - now with more Docker
NGINX 101 - now with more Docker
Introduction to Nginx
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
NGINX: Basics and Best Practices
Install nginx on ubuntu 21.04 server
NGINX: Back to Basics – APCJ
NGINX Installation and Tuning
Nginx-deploy on linux server with 80 and 442
NginX - good practices, tips and advanced techniques
Deploying nginx with minimal system resources
Nginx Scripting - Extending Nginx Functionalities with Lua
Devinsampa nginx-scripting
Nginx常见应用技术指南(Nginx Tips)
Load Balancing Container with Nginx
Ad

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Approach and Philosophy of On baking technology
PDF
Encapsulation theory and applications.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Approach and Philosophy of On baking technology
Encapsulation theory and applications.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Big Data Technologies - Introduction.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Nginx

  • 2. Nginx Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP(S), SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server).
  • 3. Installation Installation on Ubuntu sudo -s nginx=stable # use nginx=development for latest development version echo "deb http://ppa.launchpad.net/nginx/$nginx/ubuntu lucid main" > /etc/apt/sources.list. d/nginx-$nginx-lucid.list apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C apt-get update apt-get install nginx
  • 4. Configuration ● /etc/nginx ● /etc/nginx/nginx.conf # global config worker_processes 4; # = CPU Number worker_connections 65535; # max connections per process gzip on; # enable gzip gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  • 5. Configuration ● /etc/init.d/nginx {start | stop | reload | restart } ● /var/log/nginx # log ● /etc/nginx/sites-available # Virtual Host Configs, 保存配置的地方 ● /etc/nginx/sites-enabled # 要enable的配置保存的地方 ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
  • 6. Configuration server { listen 80; ## binding port server_name tiger.prod.kalengo.cn; ## domain access_log /var/log/nginx/onepiece_access.log; error_log /var/log/nginx/onepiece_error.log; root /var/www; ## website root directory location / { ...... } location /xxx { …... } location /xxx/yyy { …... } location ~* .*.(css|js)$ { add_header Cache-Control max-age=3600; } location ~ .php$ { ## pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } }
  • 7. Configuration location /files { add_header Cache-Control max-age=259200; alias /var/www/public/files; autoindex off; } location /journal { add_header Cache-Control max-age=3600; alias /var/www/public/files/journal; autoindex off; } location ~ ^/images/(w+?).jpg_(d+)x(d+) { add_header Cache-Control max-age=259200; alias /var/www/public/files/images/$2x/$1.jpg; autoindex off; } P.S: location 匹配顺序 ≠ 文件编辑顺序
  • 8. Upgrade on the Fly 1. ./configure & make a. nginx -V 2. backup & replace a. mv nginx nginx.old b. cp objs/nginx nginx 3. start & quit a. kill -USR2 b. kill -QUIT p.s: 1. Nginx平滑升级 2. Nginx Upgrade