Nginx使用技巧整理

Nginx使用技巧整理

常用命令

1
2
3
4
nginx -t            # 测试配置
nginx -s reload # 重载配置
nginx -s stop # 停止
nginx # 启动

配置文件结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
events {
worker_connections 1024;
}

http {
server {
listen 80;
server_name example.com;

location / {
proxy_pass http://localhost:8080;
}

location /static/ {
alias /path/to/static/;
}
}
}

常用功能

  • 反向代理
  • 负载均衡
  • 静态文件服务
  • SSL配置

总结

Nginx是高性能HTTP服务器。