Featured image of post nginx

nginx

# nginx常用命令

  • nginx -t:测试配置文件的正确性
  • Nginx -T: 测试配置文件,并显示配置文件(这个命令可以快速查看配置文件)
  • nginx -q:测试配置文件,但是只显示错误信息
  • nginx -s {signal}:stop, quit, reopen, reload
    • stop: 优雅退出
    • quit: 快速退出
    • reopen: 重新加载日志
    • reload: 重新加载配置
  • nginx -c:设置配置文件路径(default: /etc/nginx/nginx.conf or /usr/local/etc/nginx/nginx.conf)

# nginx proxy_pass 修改后端地址

example uri: http://localhost/api/login

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# http://localhost:8080/api/login
location /api/ {
  proxy_pass http://localhost:8080;
}
# http://localhost:8080/login
location /api/ {
  proxy_pass http://localhost:8080/;
}
# http://localhost:8080/v1/login
location /api/ {
  proxy_pass http://localhost:8080/v1/;
}