• Nginx+Keepalived+Tomcat之动静分离的web集群


    #vi /etc/nginx/nginx.conf
    ############################################
    user nginx nginx;
    worker_processes 4;
    events {
    worker_connections 1024;
    }
    http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    gzip on;
    upstream tomcat_server {
    # ip_hash;
    server 192.168.1.17 weight=2;
    server 192.168.1.20 max_fails=2 fail_timeout=30s;
    }
    upstream apache_server {
    ip_hash;
    server 192.168.1.19;
    }
    upstream nginx_server {
    ip_hash;
    server 192.168.1.18;
    }
    server
    {
    listen 80;
    server_name www.abc.com;
    location / {
    index index.html index.php index.htm index.jsp index.do default.do;
    root html;
    if (-d $request_filename)
    ###############################################
    {
    rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
    }
    location ~ .(jsp|jspx|do)?$ {
    proxy_set_header Host %host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://tomcat_server;
    }
    ###############################################
    location ~ .(php|php5)?$ {
    proxy_set_header Host %host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://nginx_server;
    }
    #############################################
    location ~ .(html|htm)?$ {
    proxy_set_header Host %host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://apache_server;
    }
    #############################################
    location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
    expires 30d;
    }
    location ~ .*.(js|css)?$ {
    expires 1h;
    }
    #############################################
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }
    }
    }

  • 相关阅读:
    Django虚拟环境创建问题virtualenvwrapper.sh: There was a problem running the initialization hooks.
    面向对象
    使用python中ssh连接CentOS7上的数据库
    Mysql在python中的使用:pymysql
    Mysql索引原理
    Mysql数据记录操作
    Mysql完整性约束
    Mysql支持的数据类型
    Mysql账户设置_增删改查_表操作
    自己项目列表
  • 原文地址:https://www.cnblogs.com/fx2008/p/4155306.html
Copyright © 2020-2023  润新知