nginx 配置文件(linux)

  1. nginx.conf
    1. user www www;
      worker_processes  8;
      
      #error_log  logs/error.log;
      #error_log  logs/error.log  notice;
      #error_log  logs/error.log  info;
      
      #pid        logs/nginx.pid;
      worker_rlimit_nofile 51200;
      
      
      events {
          use epoll;
          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  120;
          tcp_nodelay        on;
      
          #gzip  on;
          #gzip_disable "MSIE [1-6].(?!.*SV1)";
          
          client_header_buffer_size    8k;
          large_client_header_buffers  4 8k;
      
          include /opt/conf/nginx/nginx-test.conf;
      }
  2. /opt/conf/nginx/nginx-test.conf
    1.   
       upstream base{
              server ***.***.***.138:8001;
              server ***.***.***.142:8001;
          }
                 
          upstream instock{
              server ***.***.***.140:8001;
              server ***.***.***.144:8001;
          }
      
          upstream stock{
              server ***.***.***.140:8002;
              server ***.***.***.144:8002;
          }
      
          upstream outstock{
              server ***.***.***.138:8002;
              server ***.***.***.142:8002;
          }
          
       
          server {
             listen       80;     
              server_name  gzwhwms.womaiapp.com;
      
              if (-d $request_filename){
                      rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
              }
      
              location ~ ^/(WEB-INF)/ {
                       deny all;
              }
      
              #location ~ .*.(up|do|jsp|action|jhtml)?$ {
              location /outstock/ {
                  root /opt/www/outstock-web/defalut;
                  charset utf-8;
                  index   index.jsp index.action;
                  proxy_pass http://outstock;
                  include /opt/conf/nginx/proxy-resin.conf;
              }
              location /instock/ {
                  root /opt/www/instock-web/defalut;
                  charset utf-8;
                  index   index.jsp index.action;            
                  proxy_pass http://instock;
                  include /opt/conf/nginx/proxy-resin.conf;
              }
              location /stock/ {
                  root /opt/www/stock-web/defalut;
                  charset utf-8;
                  index   index.jsp index.action;
                  proxy_pass http://stock;
                  include /opt/conf/nginx/proxy-resin.conf;
              }
              location / {
                  root /opt/www/base-web/defalut;
                  charset utf-8;
                  index   index.jsp index.action;
                  proxy_pass http://base;
                  include /opt/conf/nginx/proxy-resin.conf;
              }
      
              access_log  /opt/logs/nginx/test/access.log  main;
              error_log   /opt/logs/nginx/test/error.log;
      
          }
  3. 
    
原文地址:https://www.cnblogs.com/wangzhanhua/p/10362251.html