系统相关
首页 > 系统相关> > nginx实现的一些实用性配置,持续更新中

nginx实现的一些实用性配置,持续更新中

作者:互联网

nginx实现负载均衡配置示例


#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 50m;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    upstream tomcatserver1 {  
        server 10.20.13.184:8080 weight=1; 
        server 10.20.13.185:8081 weight=1;
        server 10.20.13.186:8082 weight=1;
    } 
    server {
        listen       8888;
        server_name  127.0.0.1;
        resolver 8.8.8.8;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
        proxy_pass http://tomcatserver1;
        proxy_set_header Host $http_host;
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

nginx实现正向代理,通过内网某一台能上网的电脑联网(不支持HTTPS)


#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 50m;
    
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    server {
        listen       7777;
        resolver 8.8.8.8;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

        location / {
    #        root   html;
    #        index  index.html index.htm;
             #proxy_pass http://$http_host$request_uri;
             proxy_pass $scheme://$http_host$request_uri;
        }
    }
}

标签:index,http,更新,server,access,nginx,实用性,html,timeout
来源: https://www.cnblogs.com/zh672903/p/10911781.html