nginx配置文件主要分成4部分
http (全局配置)
server (主机配置)
upstream (负载均衡服务器配置,在http配置范围内)
location (url匹配特定位置的设置)
nginx实现的功能
1:反向代理
2:location/url重写
3:web缓存
4:负载均衡
编辑配置文件,以反向代理的方式实现负载均衡
vim /etc/nginx/nginx.conf

upstream boke_web {
    server 192.168.1.135:80;
    server 192.168.1.136:80;
}

server {
    listen 443 http2;
    ssl on;
    server_name boke.wsfnk.com;

    ssl_certificate "/etc/pki/nginx/boke_server.crt";
    ssl_certificate_key "/etc/pki/nginx/private/boke_server.key";
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:!3DES:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
    ssl_prefer_server_ciphers on;

    location / {
       proxy_pass http://boke_web;
    }

    error_page 404 /404.html;
       location = /40x.html {
       }

    error_page 500 502 503 504 /50x.html;
       location = /50x.html {
       }
}

配置好后,检查nginx配置文件的语法

nginx -c /etc/nginx/nginx.conf -t

原文来自:https://boke.wsfnk.com/archives/63.html

本文地址:https://www.linuxprobe.com/lb-nginx-keepalived.html编辑:xiangping wu,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

Linux系统大全:https://www.linuxdown.com/

红帽认证RHCE考试心得:https://www.rhce.net/