zoukankan      html  css  js  c++  java
  • nginx与tomcat整合

    nginx与tomcat整合
     
    1. 在/usr/local/nginx/conf下面添加文件proxy.conf
    # cat /usr/local/nginx/confg/proxy.conf
    proxy_redirect          off;
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr; #获取真实IP
    #proxy_set_header       X-Forwarded-For   $proxy_add_x_forwarded_for; #获取代理者的真实ip
    client_max_body_size    10m;
    client_body_buffer_size 128k;
    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;
     
    2.配置nginx.conf
    # cat /usr/local/nginx/confg/nginx.conf
    user  www www;
    worker_processes  1;
    pid     /usr/local/nginx/logs/nginx.pid;
    events {
        use epoll;
        worker_connections  1024;
    }
    http {
        include       mime.types;
        default_type  application/octet-stream;
        include     /usr/local/nginx/conf/proxy.conf;  #一定要指向代理文件
        sendfile        on;
        tcp_nopush      on;
        keepalive_timeout  65;
        server {
            listen       80;
            server_name  localhost;
            charset gb2312;
            location / {
                 root /www/web/ROOT;
                 index  index.html index.htm;
            }
            location ~ .*.jsp$ {     #匹配以jsp结尾的,tomcat的网页文件是以jsp结尾         
                    index   index.jsp;
                    proxy_pass     
     http://127.0.0.1:8080; #主要在这里,设置一个代理
            }
            location /nginxstatus {
                    stub_status on;
                    access_log on;
                    auth_basic "nginxstatus";
                    auth_basic_user_file /usr/local/nagois/etc/htpasswd.users;
            }
            # redirect server error pages to the static page /50x.html
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }
    }
     
    3.测试
    在/www/web/ROOT下添加文件index.html
    # cat index.html
    the port:80
    重启nginx
  • 相关阅读:
    Direct hosting of SMB over TCP/IP
    学习 Linux,302(混合环境): 概念
    脚本
    linux加入windows域
    Internet传输协议-TCP
    vCenter Single Sign On 5.1 best practices
    Zoning and LUN Masking
    Fiber Channel SAN Storage
    How to check WWN and Multipathing on Windows Server
    在Windows中监视IO性能
  • 原文地址:https://www.cnblogs.com/chenjw-note/p/5885939.html
Copyright © 2011-2022 走看看