• nginx学习1


    访问abc.xxx.com就跳转到www.xxx.com/abc.html

    server {
    listen 80;
    server_name abc.xxx.com;
      rewrite ^.*$ www.xxx.com/abc.html break; 
    }

     .*代表任意字符 

    访问www.a.com/a/b/c.jpg重写为www.a.com/a_b_c.jpg怎么做 
     rewrite ^www.a.com/(.*)/(.*)/(.*).jpg$ www.a.com/$1_$2_$3.jpg
     ^$表示字符串的开始和结束,()表示$1,第二个()表示$2依次类推。
    语法:rewrite 正则表达式 替代的字符串 break/last/redirect/permanent

    查看
    cd /tengine/conf/servers
    ls -lrt
    查看NGINX下所有应用的配置文件。
     
    pwd
    查看当前路径
     
    cd  ../
    回到根目录
     
    cat nginx.conf
    获取nginx.conf配置
    注意看配置包括的扩展结尾。
    #宓屽�servers/*.com;
    include servers/*.com;
    include servers/*.net;
    include servers/*.org;
    include servers/*.com.cn;
    include servers/*.cn;
    include servers/*.conf;
     
    cat buying.xxx.com
    查看当前域名配置
    upstream xxx {
             ip_hash;
            server 192.168.1.1:9002;
            server 192.168.2.2:9001;
          check interval=2000 rise=2 fall=2 timeout=1000 type=tcp;
    }
    server {
    include port.conf;
    server_name buying.xxx.com;
    include location.conf;
    include proxy.conf;
    #include rewrite.conf;
     
    location / {
                proxy_pass http://xxx;
    }
    }
     
    upstream xxx,后面跟的是集合名称,名称必须唯一。
    ip_hash;表示根据来源IP以及session控制,从哪来从哪回去。
    server后面跟的是几个节点IP
    location / {
                proxy_pass http://xxx;
    }表示buying.7881.com根目录后面直接跳到集合名称去。
     
    location ~ /purge(/.*)
    {
    allow   127.0.0.1;
    allow   192.168.0.0/16;
    allow   10.0.0.0/8;
    deny    all;
    proxy_cache_purge       cache_one       $host$1$is_args$args;
    }
     
    表示后面跟/purge来清空缓存。
     
    nginx -t
    来做NGINX的语法检查,是否配置文件配置正确。
     
    ps -ef |grep haproxy
    来查找haproxy的配置文件路径
     
    cat /usr/local/haproxy/conf/haproxy.cfg
    显示配置文件的内容
    listen  xxx
            bind 1.1.1.1:6003
            mode tcp
            option tcpka
            server _2.2.2.2_ 2.2.2.2:6003
    直接配置端口号,以及映射的IP以及端口
     
    重启haproxy服务
    /usr/local/sbin/haproxy -f /usr/local/haproxy/conf/haproxy.cfg -st `cat /usr/local/haproxy/var/haproxy.pid
     
    重启nginx服务
    nginx -s reload
    启动nginx服务
    nginx
     
    ps -ef |grep nginx
    可以看到进程是才启动的时间
  • 相关阅读:
    装饰着模式
    观察者模式
    策略模式
    nginx配置图片防盗链
    nginx配置文件详解( 看着好长,其实不长,看了就知道了,精心整理,有些配置也是没用到呢 )
    php引用计数的基本知识
    PHP运行模式
    CURL常用命令--update20151015
    memcache相同主域名下的session共享
    memcached命令行操作详解,命令选项的详细解释
  • 原文地址:https://www.cnblogs.com/itfat/p/7268154.html
Copyright © 2020-2023  润新知