Nginx配置相关

1.Nginx文件编码是UTF-8,如果用记事本打开,可能会改变文件编码格式

2.Linux默认路径

日志:/var/log/nginx

config:/etc/nginx/nginx.conf

3.负载加入

upstream ibm{
#设置分权,权重越高优先访问
server 192.0.2.172:7080 weight=1 max_fails=1 fail_timeout=60s;
server 192.0.2.173:7080 weight=1 max_fails=1 fail_timeout=60s;
ip_hash;
}

proxy_pass也需要改!!!

 4.常用维护命令

cd /usr/local/nginx/sbin
启动nginx
./nginx
关闭nginx
./nginx -s stop
重启nginx
./nginx -s reload

 

5.一段配置的例子

upstream empi{
            server 192.0.2.187:6080 weight=1 max_fails=30 fail_timeout=10s;
            server 192.0.2.188:6080 weight=1 max_fails=30 fail_timeout=10s;
            server 192.0.2.181:6210 weight=1 max_fails=30 fail_timeout=10s;
            server 192.0.2.182:6210 weight=1 max_fails=30 fail_timeout=10s;
            keepalive 500;
             }


    server {
        listen       6000;
        server_name  empi;

        location / {
            proxy_http_version 1.1;
                        proxy_set_header Connection "";
            #proxy_set_header Host $host:$server_port;
            #proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://empi;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                               root   html;
        }
    }

 

posted on 2021-01-14 11:20  巍巍之道  阅读(110)  评论(0编辑  收藏  举报

导航