服务器-Nginx配置

服务器-Nginx配置

1. 配置conf/nginx.confvhost目录中加载配置文件

使用include指令引入vhost目录下的.conf文件

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    include vhost/*.conf;

}

2. 配置允许上传的文件的最大大小

location节点下添加一行client_max_body_size 1000m;

upstream files-tech {
    server localhost:8280;
}
server {
    listen        80;
    server_name   files.iuie.tech files.iuie.pub;

    location / {
        proxy_pass             http://files-tech;
        proxy_read_timeout     300;
        proxy_send_timeout     300;
        proxy_set_header  Host  $host:80;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $http_x_forwarded_for;
        client_max_body_size    1000m;
    }
    location ~ /\.ht{
        deny all;
    }
}

3. 配置集群

upstream节点内添加多个server节点即可,这样的默认配置是以均分的方式实现负载均衡

upstream files-tech {
    server localhost:8280;
    server localhost:8380;
}
server {
    listen        80;
    server_name   files.iuie.tech files.iuie.pub;

    location / {
        proxy_pass             http://files-tech;
        proxy_read_timeout     300;
        proxy_send_timeout     300;
        proxy_set_header  Host  $host:80;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $http_x_forwarded_for;
        client_max_body_size    1000m;
    }
    location ~ /\.ht{
        deny all;
    }
}

当然,你也可以给每个节点添加权重weight,权重值越大,越容易被分配。

upstream files-tech {
    server localhost:8280 weight=1;
    server localhost:8380 weight=5;
}
...

更多关于权重的内容可以参考
http://blog.csdn.net/zhangskd/article/details/50194069

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值