Category: Web

  • fortio

    fortio load -qps 100 -n 100 https://weechoapp.com/shop_v2/api/cart/quantity?type=Product

  • G Suite 使用技巧

    公司使用 G Suite

    自己也有 google 账号,切换账号的 default

    https://support.google.com/accounts/thread/6368872?hl=en&msgid=6678524
    

    gmail settings, 关闭 chat, 打开 shortcuts

  • watch进行持续输出

    用 watch 在测试的时候可以跟进输出

    每一秒钟刷新一次

    watch -n 1 'netstat -nat | grep 211.148.19.12'

    如果想要持续性的查看,可以写到日志中

    watch -n1 'netstat -nat | grep 211.148.19.12| tee -a netstat.log'

    或者使用 sleep 来输出每一次的执行

    while sleep 1; do netstat -nat | grep 211.148.19.12; done
  • 记录指定状态码的 nginx log

    在 server 里配置,记录 403 的日志

    server {
        server_name example.com;
        access_log /var/log/nginx_access_403.log combined;
        include block_inject.conf;
        location / {
            if ($status != "403") {
                access_log off;
            }
            #......
        }
    }
    
  • nginx判断cookie 和 user-agent 跳转到 pc 或 m 站

    如果用户的 cookie 中已经访问过 m 站,或使用手机端的时候,跳转到手机端

            if ($cookie_mobile = "1") {
                rewrite ^ http://m.example.com/ redirect;
            }
            if ($http_user_agent ~* "android|iphone|ipod|windows\sphone") {
                rewrite ^ http://m.example.com/ redirect;
            }
    
  • nginx 关闭 error_log

    error_log off并不能关闭日志记录功能,它将日志文件写入一个文件名为off的文件中,如果你想关闭错误日志记录功能,应使用以下配置:

    error_log /dev/null crit;

    把存储位置设置到Linux的黑洞中去