杨叔叔 发表于 2016-12-24 11:14:18

nginx 简单配置tomcat

#usernobody;
worker_processes2;

#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
error_log/usr/local/nginx/logs/nginx_error.logcrit;
pid      /usr/local/nginx/nginx.pid;


events {
    worker_connections65535;
    use epoll;
}


http {
    include       mime.types;
    default_typeapplication/octet-stream;

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

    access_loglogs/access.logmain;

    #General Options
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_body_buffer_size    8m; #256k
    server_tokens off;
    ignore_invalid_headers   on;
    recursive_error_pages    on;
    server_name_in_redirect off;
    sendfile               on;

    #timeouts
    keepalive_timeout      60;
    #client_body_timeout   3m;
    #client_header_timeout 3m;
    #send_timeout          3m;

    #TCP Options
    tcp_nopushon;
    tcp_nodelay on;


    #size limits
    client_max_body_size       50m;

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

    upstream servers {
      
         server 192.168.1.108:8080;
         #server x.x.x.x:8080 max_fails=0 weight=1; #8080为tomcat端口
   }



    server {
      listen       80;
      server_nametest.zl.com;

      #charset koi8-r;
charset utf-8;
access_loglogs/access.logmain;
      

      location / {
            indexindex.html index.htm;
    root/prod/nginxtest;#设定访问路径
   
      }
      
location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|txt|wma)$
      {
          root /prod/nginxtest;
          expires 24h;
      }

location ~*\.(jsp|do|action)$
      {
          index index.jsp;
          proxy_pass http://localhost:8080;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header REMOTE-HOST $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }

      

location /status {
          stub_status   on;
          access_log    on;
          allow    all;
      }


      #error_page404            /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;
      }

      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ \.php$ {
      #    proxy_pass   http://127.0.0.1;
      #}

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      #location ~ \.php$ {
      #    root         html;
      #    fastcgi_pass   127.0.0.1:9000;
      #    fastcgi_indexindex.php;
      #    fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;
      #    include      fastcgi_params;
      #}

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /\.ht {
      #    denyall;
      #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_namesomenamealiasanother.alias;

    #    location / {
    #      root   html;
    #      indexindex.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_namelocalhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_keycert.key;

    #    ssl_session_timeout5m;

    #    ssl_protocolsSSLv2 SSLv3 TLSv1;
    #    ssl_ciphersHIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #      root   html;
    #      indexindex.html index.htm;
    #    }
    #}

}
页: [1]
查看完整版本: nginx 简单配置tomcat