zoukankan      html  css  js  c++  java
  • niginx相关命令及代理配置

    安装

    in mac https://www.cnblogs.com/meng1314-shuai/p/8335140.html

    Nginx相关命令

    mac下启动:

    通过brew 安装install 后
    sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
    sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist

    查看安装位置:

    ps -ef | grep nginx

    启动服务:

    sudo nginx

    停止服务:

    sudo nginx -s stop

    语法检查:

    sudo nginx -t 

    重载配置不停服:

    sudo nginx -s reload

    代理配置

    常用关键词:rewrite、proxy_pass

    location ^~ /address/ {
        proxy_set_header Host xx.sohu.com; #设置header
        proxy_set_header Origin http://xx.sohu.com;
        #proxy_set_header Cookie "$http_cookie; coder=lxf"; #一般cookie会自动转发,此处可以追加cookie
        #proxy_pass    http://192.168.1.1:8888/; # hostNow/address/a 转发至 hostOther/a,等效于下面两行,正则的时候不能加/
    	rewrite /address/(.+)$ /$1 break; #正则匹配
    	proxy_pass    http://192.168.1.1:8888;
    }
    
    location ~ (getList|search|folders) { #正则匹配
        proxy_set_header Host free-mail-backend-test.sce.sohuno.com;
        proxy_set_header Origin http://free-mail-backend-test.sce.sohuno.com;
        proxy_pass    http://free-mail-backend-test.sce.sohuno.com;
    }
    

      

    其他:

    Nginx中不允许if嵌套;

    不能设置逻辑运算符(比如啊A&&B),实现逻辑运算只能通过累加计数器或者写到正则里,如下:

    location / {
        alias /opt/src/app/;
        expires 24h;
        set $myindex index.html;
        #MSIE 6-7 且 XP或Vista系统 才认为是IE6-7
        if ($http_user_agent ~* "MSIE [6-7].d.+Windows NT (5.|6.0)") {
            set $myindex browserGuide.html;
        }
        index $myindex;
    }

    参考:

    http://www.cnblogs.com/AloneSword/p/3673829.html
    http://linux.it.net.cn/e/server/nginx/2014/0709/2704.html

  • 相关阅读:
    MERGE同步
    SqlServer中decimal(numeric )、float 和 real 数据类型的区别
    Hashtable
    SQL Server 数据类型 float, real, money, decimal, numeric
    QA常见面试问题答与问(English)zt
    MSDN 代码审查
    security testing
    SQL Server:无日志恢复数据库
    SQL Server 2005 数据库快照(database Snapshot)
    备份和恢复概述zt
  • 原文地址:https://www.cnblogs.com/youryida/p/5422067.html
Copyright © 2011-2022 走看看