xuxiaohui9216 发表于 2018-11-9 07:46:34

nginx多端口转发

  # cat nginx.conf
  usernginx nginx;
  worker_processes 8;
  error_log/opt/nginx/logs/nginx_error.logcrit;
  pid      /opt/nginx/logs/nginx.pid;
  worker_rlimit_nofile 51200;
  events
  {
  use epoll;
  worker_connections 51200;
  }
  http
  {
  include       mime.types;
  default_typeapplication/octet-stream;
  #charsetgb2312;
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  sendfile on;
  tcp_nopush   on;
  keepalive_timeout 60;
  tcp_nodelay on;
  gzip on;
  #gzip_min_length1k;
  #gzip_buffers   4 16k;
  #gzip_http_version 1.0;
  #gzip_comp_level 2;
  #gzip_types       text/plain application/x-javascript text/css application/xml;
  #gzip_vary on;
  upstreamweb.abc.com{
  ip_hash;
  server   192.168.5.91:8382;
  server   192.168.5.91:8383;
  server   192.168.5.91:8384;
  server   192.168.5.91:8385;
  }
  server
  {
  listen8181;
  server_name localhost;
  proxy_redirect off;
  #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
  proxy_set_header   X-Forwarded-For$remote_addr;
  #      if ($request_uri   ~*   ".*\.(js|css|gif|jpg|jpeg|png|bmp|swf)$")
  #      {
  #                proxy_pass http://squid.abc.com;
  #      }
  #      if ($request_uri   ~*   "^/view/(.*)$")
  #      {
  #                proxy_pass http://squid.abc.com;
  #      }
  #      proxy_pass http://web.abc.com;
  location /chinawidth {
  #aliashtml/;
  proxy_pass http://web.abc.com;
  indexindex.html index.htm index.jpg index.pwp;
  }
  location /iflashbuy {
  #aliashtml/;
  proxy_pass http://web.abc.com;
  indexindex.html index.htm index.jpg index.pwp;
  }
  #定义日志格式
  #      log_formataccess'$remote_addr - $remote_user [$time_local] $request '
  #                   '"$status" $body_bytes_sent "$http_referer" '
  #                   '"$http_user_agent" "$http_x_forwarded_for"';
  #打日志
  access_log/opt/nginx/logs/access.logaccess;
  #允许客户端请求的最大的单个文件字节数
  client_max_body_size   10m;
  #缓冲区代理缓冲用户端请求的最大字节数 可以理解为先保存到本地再传给用户
  client_body_buffer_size128k;
  #跟后端服务器连接的超时时间_发起握手等候响应超时时间
  proxy_connect_timeout    600;
  #连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理
  proxy_read_timeout       600;
  #后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
  proxy_send_timeout       600;
  #代理请求缓存区_这个缓存区间会保存用户的头信息以供Nginx进行规则处理_一般只要能保存下头信息即可
  proxy_buffer_size      8k;
  #同上 告诉Nginx保存单个用的几个Buffer 最大用多大空间
  proxy_buffers            4 32k;
  #如果系统很忙的时候可以申请更大的proxy_buffers 官方推荐*2
  proxy_busy_buffers_size 64k;
  #proxy缓存临时文件的大小
  proxy_temp_file_write_size 64k;
  }
  }

页: [1]
查看完整版本: nginx多端口转发