Nginx基本命令:
nginx -s quit 优雅停止nginx,有连接时会等连接请求完成再杀死worker进程
nginx -s reload 优雅重启,并重新载入配置文件nginx.conf
nginx -s reopen 重新打开日志文件,一般用于切割日志
nginx -v 查看版本
nginx -t 检查nginx的配置文件
nginx -h 查看帮助信息
nginx -V 详细版本信息,包括编译参数
nginx -c filename 指定配置文件
nginx -c /etc/nginx/nginx.conf 重启nginx
-c /etc/nginx/nginx.conf 更新配置文件
省略打包SpringBoot项目。。。
配置Nginx项目:
nginx打开配置文件
vim /etc/nginx/conf/nginx.conf
注意:nginx/1.10.3 (Ubuntu) 版本的,打开/etc/nginx/sites-enabled/default
添加如下配置信息到http模块里面
upstream test {
server 127.0.0.1:8080 weight=10;
}
server {
listen 80; # 默认监听端口80
server_name cc520.me;# 对外服务名
# …其他配置信息
# 配置代理路径
location /test {
proxy_pass http://test/;
}
# 对“/”路径转发 /test
location = / {
return 302 /test ;
}
# …其他配置信息
}
如要轮询策略进行服务分发:
upstream test {
server 127.0.0.1:8080 weight=10; #轮询1
server 127.0.0.1:8080 weight=10; #轮询2
server 127.0.0.1:8080 weight=10; #轮询3
}
server {
listen 80; # 默认监听端口80
server_name cc520.me;# 对外服务名
# …其他配置信息
# 配置代理路径
location /test {
proxy_pass http://test/;
}
# 对“/”路径转发 /test 不配302 访问root目录项目
location = / {
return 302 /test ;
}
# …其他配置信息
}
参考文章:https://www.cnblogs.com/Franken-Fran/p/nginx_balanceLoad.html
参考react部署文章:https://www.jianshu.com/p/5d7238a51b1c