nginx反向代理

守給你的承諾、 提交于 2019-11-26 03:34:28

user  nginx;
worker_processes  auto;

#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;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    upstream www {  
        server 192.168.1.125:81 weight=1 max_fails=2 fail_timeout=3;

  server 192.168.1.124:83 weight=1 max_fails=2 fail_timeout=3;

  server 192.168.1.123:84 weight=1 max_fails=2 fail_timeout=3;
        }
        upstream images {
        server 192.168.1.125:82 weight=1 max_fails=2 fail_timeout=3;
                }

        upstream app {
        server 192.168.1.125:83 weight=1 max_fails=2 fail_timeout=3;
  server 192.168.1.122:81 weight=1 max_fails=2 fail_timeout=3;      

          }

        upstream upload {
        server 192.168.1.125:84 weight=1 max_fails=2 fail_timeout=3;
                }

        upstream help {
        server 192.168.1.125:85 weight=1 max_fails=2 fail_timeout=3;
                }

        upstream cg {
        server 192.168.1.125:86 weight=1 max_fails=2 fail_timeout=3;
                }

        upstream res {
        server 192.168.1.125:87 weight=1 max_fails=2 fail_timeout=3;
                }

server {  
  listen   80;
    server_name  www.dzerc.net;
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://www;
    proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";            
     }
}
server {
  listen   80;
    server_name  images.dzerc.net;    
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://images;
        proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
     }
}
server {
  listen   80;
    server_name  app.dzerc.net;    
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://app;
        proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
     }
}
server {
  listen   80;
    server_name  upload.dzerc.net;    
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://upload;
        proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
     }
}
server {
  listen   80;
    server_name  help.dzerc.net;    
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://help;
        proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
     }
}
server {
  listen   80;
    server_name  cg.dzerc.net;    
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://cg;
        proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
     }
}
server {
  listen   80;
    server_name  res.dzerc.net;    
    large_client_header_buffers 4 16k;
    client_max_body_size 300m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 64k;
    proxy_buffers   4 32k;
    proxy_busy_buffers_size 64k;
    location / {
        proxy_pass http://res;
        proxy_cache_key $host$uri$is_args$args;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
     }
    }
include /etc/nginx/conf/*.conf;    
}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!