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
  • 相关阅读:
    canvas实现音乐中的歌词播放效果
    canvas调节视频颜色
    clip API实现遮罩
    总有那么几款发型 是经典不过时的
    很多人喜欢露脚踝你觉得时尚吗?
    王者荣耀花木兰攻略解析
    十位王者给出的单排心得
    IntelliJ IDEA2017 + tomcat 即改即生效 实现热部署
    IntelliJ IDEA2017 + tomcat 即改即生效 实现热部署
    jqGrid分页查询出错
  • 原文地址:https://www.cnblogs.com/chenjw-note/p/5885939.html
Copyright © 2011-2022 走看看