🌍Nginx Server Block
Also known as Server Block, Nginx server Directive
The Nginx settings block for one site: its port, its names and its folder.
Think of it like
It is like one drawer in a big desk. Each drawer holds the papers for one site.
Example
Jack's server has two server blocks. One answers example.com on port 443. The other sends plain HTTP on port 80 over to HTTPS.
Why it matters
Definition
Example code
nginx
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
index index.html;
}Common mistake
Key takeaways
- 1One site. Each block is one virtual host.
- 2listen and server_name. The port and the names it answers.
- 3root. The folder it serves from.