Nginx配置部署SpringBoot项目

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

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值