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
  • 相关阅读:
    修改某路径下的文件名
    关于提取字符串中数字
    解决采集知乎数据时由于账号被封遗漏的账号重爬问题(python代码)
    project proposal写作框架
    PHP实现生成透明背景的PNG缩略图函数
    PHP中的绝对和相对路径解析
    js设置页面锚点
    列表顺序储存
    c++修饰符重载
    c++配置文件读取、修改、添加
  • 原文地址:https://www.cnblogs.com/chenjw-note/p/5885939.html
Copyright © 2011-2022 走看看