SlideShare a Scribd company logo
Nginx Cheat Sheet
Nginx is a web server which can also be used as a reverse proxy, load balancer, mail
proxy and HTTP cache.
by lam
󰅂General Settings
Port (listen)
server {
# standard HTTP proto
col
listen 80;
# standard HTTPS prot
ocol
listen 443 ssl;
# listen on 80 using
IPv6
listen [::]:80;
# listen only on IPv6
listen [::]:80 ipv6on
ly=on;
}
Domain name (server_name)
server {
# Listen to yourdomai
n.com
server_name yourdomai
n.com;
# Listen to multiple
domains
server_name yourdomai
n.com www.yourdomain.co
m;
# Listen to all sub-d
omains
server_name *.yourdom
ain.com;
# Listen to all top-l
evel domains
server_name yourdomai
n.*;
# Listen to unspecifi
ed hostnames (listens t
o IP address itself)
󰅂Serving Files
Static assets
server {
listen 80;
server_name yourdomai
n.com;
location / {
root /path/to/w
ebsite;
}
}
Static assets with HTML5
History Mode
server {
listen 80;
server_name yourdomai
n.com;
root /path/to/websit
e;
location / {
try_files $uri
$uri/ /index.html;
}
}
󰅂Redirects
301 Permanent
Useful for handling
www.yourdomain.com vs.
yourdomain.com or
redirecting http to https. In
this case we will redirect
www.yourdomain.com to
yourdomain.com.
server {
listen 80;
server_name www.yourd
omain.com;
return 301 http://you
rdomain.com$request_ur
i;
}
302 Temporary
server {
listen 80;
server_name yourdomai
n.com;
return 302 http://oth
erdomain.com;
}
Redirect on speci c URL
Can be permanent (301) or
temporary (302).
server {
listen 80;
server_name yourdomai
n.com;
location /redirect-ur
l {
return 301 htt
p://otherdomain.com;
}
}
󰅂Reverse Proxy
Basic
server {
listen 80;
server_name yourdomai
n.com;
location / {
proxy_pass http://
0.0.0.0:3000;
# where 0.0.0.0:300
0 is your Node.js Serve
r bound on 0.0.0.0 list
ing on port 3000
}
}
󰅂TLS/SSL (HTTPS)
󰏪
󰅢
server_name "";
}
Access Logging (access_log)
server {
# Relative or full pa
th to log file
access_log /path/to/f
ile.log;
# Turn 'on' or 'off'
access_log on;
}
Miscellaneous (gzip,
client_max_body_size)
server {
# Turn gzip compressi
on 'on' or 'off'
gzip on;
# Limit client body s
ize to 10mb
client_max_body_size
10M;
}
Basic+
upstream node_js {
server 0.0.0.0:3000;
# where 0.0.0.0:3000 i
s your Node.js Server b
ound on 0.0.0.0 listin
g on port 3000
}
server {
listen 80;
server_name yourdomai
n.com;
location / {
proxy_pass http://no
de_js;
}
}
Upgraded Connection
(Recommended for Node.js
Applications)
Useful for Node.js
applications with support for
WebSockets like socket.io.
upstream node_js {
server 0.0.0.0:3000;
}
server {
listen 80;
server_name yourdomai
n.com;
location / {
proxy_pass http://n
ode_js;
proxy_redirect off;
proxy_http_version
1.1;
proxy_set_header Up
grade $http_upgrade;
proxy_set_header Co
nnection "upgrade";
proxy_set_header Ho
st $host;
# not required but
useful for application
s with heavy WebSocket
usage
# as it increases t
he default timeout conf
If you are looking for free
SSL certi cates, Let's
Encrypt is a free,
automated, and open
Certi cate Authority. Also,
here is a wonderful step-by-
step guide from Digital
Ocean on how to setup
TLS/SSL on Ubuntu 16.04.
server {
listen 443 ssl;
server_name yourdoma
in.com;
ssl on;
ssl_certificate /pat
h/to/cert.pem;
ssl_certificate_key
/path/to/privkey.pem;
ssl_stapling on;
ssl_stapling_verify
on;
ssl_trusted_certific
ate /path/to/fullchai
n.pem;
ssl_protocols TLSv1
TLSv1.1 TLSv1.2;
ssl_session_timeout
1d;
ssl_session_cache sh
ared:SSL:50m;
add_header Strict-Tr
ansport-Security max-a
ge=15768000;
}
# Permanent redirect f
or HTTP to HTTPS
server {
listen 80;
server_name yourdoma
in.com;
return 301 https://
$host$request_uri;
}
󰅂
Large Scale
Applications
Load Balancing
upstream node_js {
server 0.0.0.0:3000;
server 0.0.0.0:4000;
server 123.131.121.12
2;
}
server {
listen 80;
server_name yourdomai
n.com;
location / {
proxy_pass http://n
ode_js;
}
}
󰏪
󰅢
CheatSheetMaker.com SimpleCheatSheet.com
iguration of 60
proxy_read_timeout
80;
}
}
󰏪
󰅢

More Related Content

What's hot

NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load Balancing
NGINX, Inc.
 
Using NGINX as an Effective and Highly Available Content Cache
Using NGINX as an Effective and Highly Available Content CacheUsing NGINX as an Effective and Highly Available Content Cache
Using NGINX as an Effective and Highly Available Content Cache
Kevin Jones
 
Day 5.5 subnetting
Day 5.5 subnettingDay 5.5 subnetting
Day 5.5 subnetting
CYBERINTELLIGENTS
 
Introduction to NGINX web server
Introduction to NGINX web serverIntroduction to NGINX web server
Introduction to NGINX web server
Md Waresul Islam
 
Load Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXLoad Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINX
NGINX, Inc.
 
NGINX ADC: Basics and Best Practices – EMEA
NGINX ADC: Basics and Best Practices – EMEANGINX ADC: Basics and Best Practices – EMEA
NGINX ADC: Basics and Best Practices – EMEA
NGINX, Inc.
 
Python Basics
Python BasicsPython Basics
Python Basics
tusharpanda88
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and how
Altinity Ltd
 
Network scanning
Network scanningNetwork scanning
Network scanning
MD SAQUIB KHAN
 
Open vSwitch - Stateful Connection Tracking & Stateful NAT
Open vSwitch - Stateful Connection Tracking & Stateful NATOpen vSwitch - Stateful Connection Tracking & Stateful NAT
Open vSwitch - Stateful Connection Tracking & Stateful NAT
Thomas Graf
 
Tools kali
Tools kaliTools kali
Tools kali
ketban0702
 
How to Get Started With NGINX
How to Get Started With NGINXHow to Get Started With NGINX
How to Get Started With NGINX
NGINX, Inc.
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
Larry Cai
 
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
PROIDEA
 
5 things you didn't know nginx could do
5 things you didn't know nginx could do5 things you didn't know nginx could do
5 things you didn't know nginx could do
sarahnovotny
 
Nmap basics
Nmap basicsNmap basics
Ethical hacking Chapter 7 - Enumeration - Eric Vanderburg
Ethical hacking   Chapter 7 - Enumeration - Eric VanderburgEthical hacking   Chapter 7 - Enumeration - Eric Vanderburg
Ethical hacking Chapter 7 - Enumeration - Eric Vanderburg
Eric Vanderburg
 
Ip tunnelling and_vpn
Ip tunnelling and_vpnIp tunnelling and_vpn
Ip tunnelling and_vpn
Rajesh Porwal
 
Access Control List (ACL)
Access Control List (ACL)Access Control List (ACL)
Access Control List (ACL)
ISMT College
 
Wireshark Tutorial
Wireshark TutorialWireshark Tutorial
Wireshark Tutorial
Coursenvy.com
 

What's hot (20)

NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load Balancing
 
Using NGINX as an Effective and Highly Available Content Cache
Using NGINX as an Effective and Highly Available Content CacheUsing NGINX as an Effective and Highly Available Content Cache
Using NGINX as an Effective and Highly Available Content Cache
 
Day 5.5 subnetting
Day 5.5 subnettingDay 5.5 subnetting
Day 5.5 subnetting
 
Introduction to NGINX web server
Introduction to NGINX web serverIntroduction to NGINX web server
Introduction to NGINX web server
 
Load Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINXLoad Balancing and Scaling with NGINX
Load Balancing and Scaling with NGINX
 
NGINX ADC: Basics and Best Practices – EMEA
NGINX ADC: Basics and Best Practices – EMEANGINX ADC: Basics and Best Practices – EMEA
NGINX ADC: Basics and Best Practices – EMEA
 
Python Basics
Python BasicsPython Basics
Python Basics
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and how
 
Network scanning
Network scanningNetwork scanning
Network scanning
 
Open vSwitch - Stateful Connection Tracking & Stateful NAT
Open vSwitch - Stateful Connection Tracking & Stateful NATOpen vSwitch - Stateful Connection Tracking & Stateful NAT
Open vSwitch - Stateful Connection Tracking & Stateful NAT
 
Tools kali
Tools kaliTools kali
Tools kali
 
How to Get Started With NGINX
How to Get Started With NGINXHow to Get Started With NGINX
How to Get Started With NGINX
 
Learn nginx in 90mins
Learn nginx in 90minsLearn nginx in 90mins
Learn nginx in 90mins
 
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
 
5 things you didn't know nginx could do
5 things you didn't know nginx could do5 things you didn't know nginx could do
5 things you didn't know nginx could do
 
Nmap basics
Nmap basicsNmap basics
Nmap basics
 
Ethical hacking Chapter 7 - Enumeration - Eric Vanderburg
Ethical hacking   Chapter 7 - Enumeration - Eric VanderburgEthical hacking   Chapter 7 - Enumeration - Eric Vanderburg
Ethical hacking Chapter 7 - Enumeration - Eric Vanderburg
 
Ip tunnelling and_vpn
Ip tunnelling and_vpnIp tunnelling and_vpn
Ip tunnelling and_vpn
 
Access Control List (ACL)
Access Control List (ACL)Access Control List (ACL)
Access Control List (ACL)
 
Wireshark Tutorial
Wireshark TutorialWireshark Tutorial
Wireshark Tutorial
 

Similar to Nginx cheat sheet

ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
Ortus Solutions, Corp
 
Virtual host examples_-_apache_http_server
Virtual host examples_-_apache_http_serverVirtual host examples_-_apache_http_server
Virtual host examples_-_apache_http_server
HARRY CHAN PUTRA
 
NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)
Marcel Cattaneo
 
Http
HttpHttp
Apache HTTP Server
Apache HTTP ServerApache HTTP Server
Apache HTTP Server
Tan Huynh Cong
 
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
LumoSpark
 
Apache
ApacheApache
Apache
Rathan Raj
 
Web Server Administration
Web Server AdministrationWeb Server Administration
Web Server Administration
webhostingguy
 
Web Server Administration
Web Server AdministrationWeb Server Administration
Web Server Administration
webhostingguy
 
Web Server Administration
Web Server AdministrationWeb Server Administration
Web Server Administration
webhostingguy
 
APACHE 2 HTTPS.ppt
APACHE 2 HTTPS.pptAPACHE 2 HTTPS.ppt
APACHE 2 HTTPS.ppt
webhostingguy
 
Under the Covers with the Web
Under the Covers with the WebUnder the Covers with the Web
Under the Covers with the Web
Trevor Lohrbeer
 
are available here
are available hereare available here
are available here
webhostingguy
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
Information Technology
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]
Krisman Tarigan
 
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdfITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
Ortus Solutions, Corp
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
Rich Bowen
 
Linux administration ii-parti
Linux administration ii-partiLinux administration ii-parti
Linux administration ii-parti
Sehla Loussaief Zayen
 
SquirrelMail for webmail
SquirrelMail for webmailSquirrelMail for webmail
SquirrelMail for webmail
Aryman Gautam
 
Apache installation and configurations
Apache installation and configurationsApache installation and configurations
Apache installation and configurations
Nikhil Jain
 

Similar to Nginx cheat sheet (20)

ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
 
Virtual host examples_-_apache_http_server
Virtual host examples_-_apache_http_serverVirtual host examples_-_apache_http_server
Virtual host examples_-_apache_http_server
 
NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)NGiNX, VHOSTS & SSL (let's encrypt)
NGiNX, VHOSTS & SSL (let's encrypt)
 
Http
HttpHttp
Http
 
Apache HTTP Server
Apache HTTP ServerApache HTTP Server
Apache HTTP Server
 
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
How to turn any dynamic website into a static site | 24.01.2018 | Artem Danil...
 
Apache
ApacheApache
Apache
 
Web Server Administration
Web Server AdministrationWeb Server Administration
Web Server Administration
 
Web Server Administration
Web Server AdministrationWeb Server Administration
Web Server Administration
 
Web Server Administration
Web Server AdministrationWeb Server Administration
Web Server Administration
 
APACHE 2 HTTPS.ppt
APACHE 2 HTTPS.pptAPACHE 2 HTTPS.ppt
APACHE 2 HTTPS.ppt
 
Under the Covers with the Web
Under the Covers with the WebUnder the Covers with the Web
Under the Covers with the Web
 
are available here
are available hereare available here
are available here
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
 
17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]17937858 squid-server - [the-xp.blogspot.com]
17937858 squid-server - [the-xp.blogspot.com]
 
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdfITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
 
Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011Apache Wizardry - Ohio Linux 2011
Apache Wizardry - Ohio Linux 2011
 
Linux administration ii-parti
Linux administration ii-partiLinux administration ii-parti
Linux administration ii-parti
 
SquirrelMail for webmail
SquirrelMail for webmailSquirrelMail for webmail
SquirrelMail for webmail
 
Apache installation and configurations
Apache installation and configurationsApache installation and configurations
Apache installation and configurations
 

More from Lam Hoang

Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.com
Lam Hoang
 
VS Code cheat sheet
VS Code cheat sheetVS Code cheat sheet
VS Code cheat sheet
Lam Hoang
 
PostgreSql cheat sheet
PostgreSql cheat sheetPostgreSql cheat sheet
PostgreSql cheat sheet
Lam Hoang
 
MySql cheat sheet
MySql cheat sheetMySql cheat sheet
MySql cheat sheet
Lam Hoang
 
Html cheat sheet
Html cheat sheetHtml cheat sheet
Html cheat sheet
Lam Hoang
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
Lam Hoang
 
Django cheat sheet
Django cheat sheetDjango cheat sheet
Django cheat sheet
Lam Hoang
 
Css cheat sheet
Css cheat sheetCss cheat sheet
Css cheat sheet
Lam Hoang
 
Apache cheat sheet
Apache cheat sheetApache cheat sheet
Apache cheat sheet
Lam Hoang
 
Battle chatter minecraft 1.4.7 mod
Battle chatter minecraft 1.4.7 modBattle chatter minecraft 1.4.7 mod
Battle chatter minecraft 1.4.7 mod
Lam Hoang
 
On thi dai_hoc_mon_van_2010 (1)
On thi dai_hoc_mon_van_2010 (1)On thi dai_hoc_mon_van_2010 (1)
On thi dai_hoc_mon_van_2010 (1)Lam Hoang
 
ôn thi môn văn
ôn thi môn vănôn thi môn văn
ôn thi môn vănLam Hoang
 
On thi dai_hoc_mon_van_2010
On thi dai_hoc_mon_van_2010On thi dai_hoc_mon_van_2010
On thi dai_hoc_mon_van_2010Lam Hoang
 
giáo trình c căn bản
giáo trình c căn bảngiáo trình c căn bản
giáo trình c căn bảnLam Hoang
 

More from Lam Hoang (14)

Py spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.comPy spark cheat sheet by cheatsheetmaker.com
Py spark cheat sheet by cheatsheetmaker.com
 
VS Code cheat sheet
VS Code cheat sheetVS Code cheat sheet
VS Code cheat sheet
 
PostgreSql cheat sheet
PostgreSql cheat sheetPostgreSql cheat sheet
PostgreSql cheat sheet
 
MySql cheat sheet
MySql cheat sheetMySql cheat sheet
MySql cheat sheet
 
Html cheat sheet
Html cheat sheetHtml cheat sheet
Html cheat sheet
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Django cheat sheet
Django cheat sheetDjango cheat sheet
Django cheat sheet
 
Css cheat sheet
Css cheat sheetCss cheat sheet
Css cheat sheet
 
Apache cheat sheet
Apache cheat sheetApache cheat sheet
Apache cheat sheet
 
Battle chatter minecraft 1.4.7 mod
Battle chatter minecraft 1.4.7 modBattle chatter minecraft 1.4.7 mod
Battle chatter minecraft 1.4.7 mod
 
On thi dai_hoc_mon_van_2010 (1)
On thi dai_hoc_mon_van_2010 (1)On thi dai_hoc_mon_van_2010 (1)
On thi dai_hoc_mon_van_2010 (1)
 
ôn thi môn văn
ôn thi môn vănôn thi môn văn
ôn thi môn văn
 
On thi dai_hoc_mon_van_2010
On thi dai_hoc_mon_van_2010On thi dai_hoc_mon_van_2010
On thi dai_hoc_mon_van_2010
 
giáo trình c căn bản
giáo trình c căn bảngiáo trình c căn bản
giáo trình c căn bản
 

Recently uploaded

BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 

Recently uploaded (20)

BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 

Nginx cheat sheet

  • 1. Nginx Cheat Sheet Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. by lam 󰅂General Settings Port (listen) server { # standard HTTP proto col listen 80; # standard HTTPS prot ocol listen 443 ssl; # listen on 80 using IPv6 listen [::]:80; # listen only on IPv6 listen [::]:80 ipv6on ly=on; } Domain name (server_name) server { # Listen to yourdomai n.com server_name yourdomai n.com; # Listen to multiple domains server_name yourdomai n.com www.yourdomain.co m; # Listen to all sub-d omains server_name *.yourdom ain.com; # Listen to all top-l evel domains server_name yourdomai n.*; # Listen to unspecifi ed hostnames (listens t o IP address itself) 󰅂Serving Files Static assets server { listen 80; server_name yourdomai n.com; location / { root /path/to/w ebsite; } } Static assets with HTML5 History Mode server { listen 80; server_name yourdomai n.com; root /path/to/websit e; location / { try_files $uri $uri/ /index.html; } } 󰅂Redirects 301 Permanent Useful for handling www.yourdomain.com vs. yourdomain.com or redirecting http to https. In this case we will redirect www.yourdomain.com to yourdomain.com. server { listen 80; server_name www.yourd omain.com; return 301 http://you rdomain.com$request_ur i; } 302 Temporary server { listen 80; server_name yourdomai n.com; return 302 http://oth erdomain.com; } Redirect on speci c URL Can be permanent (301) or temporary (302). server { listen 80; server_name yourdomai n.com; location /redirect-ur l { return 301 htt p://otherdomain.com; } } 󰅂Reverse Proxy Basic server { listen 80; server_name yourdomai n.com; location / { proxy_pass http:// 0.0.0.0:3000; # where 0.0.0.0:300 0 is your Node.js Serve r bound on 0.0.0.0 list ing on port 3000 } } 󰅂TLS/SSL (HTTPS) 󰏪 󰅢
  • 2. server_name ""; } Access Logging (access_log) server { # Relative or full pa th to log file access_log /path/to/f ile.log; # Turn 'on' or 'off' access_log on; } Miscellaneous (gzip, client_max_body_size) server { # Turn gzip compressi on 'on' or 'off' gzip on; # Limit client body s ize to 10mb client_max_body_size 10M; } Basic+ upstream node_js { server 0.0.0.0:3000; # where 0.0.0.0:3000 i s your Node.js Server b ound on 0.0.0.0 listin g on port 3000 } server { listen 80; server_name yourdomai n.com; location / { proxy_pass http://no de_js; } } Upgraded Connection (Recommended for Node.js Applications) Useful for Node.js applications with support for WebSockets like socket.io. upstream node_js { server 0.0.0.0:3000; } server { listen 80; server_name yourdomai n.com; location / { proxy_pass http://n ode_js; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Up grade $http_upgrade; proxy_set_header Co nnection "upgrade"; proxy_set_header Ho st $host; # not required but useful for application s with heavy WebSocket usage # as it increases t he default timeout conf If you are looking for free SSL certi cates, Let's Encrypt is a free, automated, and open Certi cate Authority. Also, here is a wonderful step-by- step guide from Digital Ocean on how to setup TLS/SSL on Ubuntu 16.04. server { listen 443 ssl; server_name yourdoma in.com; ssl on; ssl_certificate /pat h/to/cert.pem; ssl_certificate_key /path/to/privkey.pem; ssl_stapling on; ssl_stapling_verify on; ssl_trusted_certific ate /path/to/fullchai n.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_session_timeout 1d; ssl_session_cache sh ared:SSL:50m; add_header Strict-Tr ansport-Security max-a ge=15768000; } # Permanent redirect f or HTTP to HTTPS server { listen 80; server_name yourdoma in.com; return 301 https:// $host$request_uri; } 󰅂 Large Scale Applications Load Balancing upstream node_js { server 0.0.0.0:3000; server 0.0.0.0:4000; server 123.131.121.12 2; } server { listen 80; server_name yourdomai n.com; location / { proxy_pass http://n ode_js; } } 󰏪 󰅢
  • 3. CheatSheetMaker.com SimpleCheatSheet.com iguration of 60 proxy_read_timeout 80; } } 󰏪 󰅢