nginx 配置备忘

来源:互联网 发布:鲨鱼网络 编辑:程序博客网 时间:2024/06/11 17:29

持续更新,个人使用

#user  nobody;#进程数worker_processes  1;#错误日志配置error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#pid        logs/nginx.pid;#连接数配置events {    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    sendfile        on;    keepalive_timeout  65;    gzip  on;    server {        listen       80;        server_name  localhost;        access_log  logs/host.access.log  main;        location / {            root   html;            index  index.html index.htm;        }        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   html;        }        #负载均衡配置        location /proxy {            proxy_pass http://backend        }        #上游服务器配置        upstream backend {            #负载均衡算法配置:             #round-robin(轮询,默认)            #ip_hash(根据 IP 哈希)            #hash key [consistent](根据指定的 key 哈希,可选一致性哈希)            round-robin;            #权重: weight            server 10.20.30.1:8080 weight=1            #失败重试: fail_timeout 时间内失败了 max_fails 次数,将摘掉上游服务器,fail_timeout 过后再次加入到存活服务器列表进行尝试            server 10.20.30.2:8080 max_fails=2 fail_timeout=10s weight=2        }    }}