存在的记忆

nginx 代理转发

upstream 负载均衡模块

upstream apache_cluster{
        #dynamic_resolve fallback=stale fail_timeout=3s;
        # server 1-1.host :80
        server 10.0.0.1:8080 max_fails=3 fail_timeout=10;
}

proxy_pass 转发 (nginx、apache、wsgi...)

server {
        listen 80;
        server_name apache.com;
location / {
        #proxy_pass http://127.0.0.1:9000; #单节点可以不用upstream
        proxy_pass  http://apache_cluster;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        
        proxy_max_temp_file_size 0;
        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k; 

   }
}

转第三方接口

location /unionpay/ {
         proxy_set_header Host gateway.银联.com;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_pass https://gateway.银联.com/;
}

ajp 长连接(jboss

https://github.com/yaoweibin/nginx_ajp_module

        location ~ ^/imageTempUpload.htm$ {
                proxy_pass http://upload.com;
                index /imageTempUpload.htm;
        }
        location ~* (\/$)|\.(do|json|jsx|tile|resource|file|htm|checkcode|s)$ {
                #if ( $request_uri = "/" ) {
                #rewrite "/" $uri/index.htm break;
                #}
                ajp_connect_timeout 120s;   #连接超时时间
                ajp_keep_conn on;      #保持回话
                ajp_pass jboss_cluster; #upstream负载
                index index.htm;

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »