Nginx 使用笔记

  • 反向代理
  • 负载均衡
  • 动静分离

架构的核心思想——分层
VPN 正向代理

Nginx

内存占用小,支持5万的高并发

启动需要英文目录

  1. linux 中 解压执行 configure 文件
  2. 未报错 执行 makemake install
  3. whereis nginx 找到安装目录
  4. sbin 下可启动 nginx;conf 下可配置 nginx;

error: C compiler cc is not found

yum -y install gcc-c++ autoconf automake

常见出错及解决方案

error: the HTTP rewrite module requires the PCRE library

 yum install -y pcre pcre-devel

error: the HTTP gzip module requires the zlib library

yum install -y zlib zlib-devel

基本命令

./nginx # 启动
./nginx -s stop # 停止
./nginx -s quit # 安全退出
./nginx -s reload # 重载

配置 nginx.conf

80 rewrite 433

root nginx前端页面路径

http {
  # http 配置
  upstream xxxx {
    # 负载均衡设置
    server 主机 weight=1;
  }
  server {
    listen 80;
    server_name localhost;
  }
    server {
      listen 443;
      server_name localhost;
      location / {
        root /home/xx; # 前端静态文件;
        index  index.html index.htm;
      }
      location /api {
        proxy_pass http://127.0.0.1:8080; # 配置代理
        rewrite "^/api/(.*)$" /$1 break;
      }
    }
}

location :一个server下可以有多个location ,用来匹配 同一个域名下不同uri的访问
location [=|~ | ~* |^~|@] /uri/ { - }
普通 无开头引量字符或以 = 开头表示普通字符匹配
正则~~ * 开头表示正则匹配,~ * 表示不区分大小写

Redis - Session 会话共享

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值