nginx upstream based on http header

Read full article  | 评论关闭

upstream apache {
     server 127.0.0.1:8080;
}

upstream staging {
     server 127.0.0.1:8081;
}

upstream development {
     server 127.0.0.1:8082;
}

# map to different upstream backends based on header
map $http_x_server_select $pool {
     default "apache";
     staging "staging";
     dev "development";
}

server {
     listen 80;
     server_name example.com;
     location / {
          proxy_pass http://$pool;

          #standard proxy settings
          proxy_set_header X-Real-IP $remote_addr;
          proxy_redirect off;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_redirect off;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-NginX-Proxy true;
          proxy_connect_timeout 600;
          proxy_send_timeout 600;
          proxy_read_timeout 600;
          send_timeout 600;
     }
}

Read More

mongo collection name have -

Read full article  | 评论关闭

 

 

db['construction-places'].count()
42

Read More

BMI 计算公式

Read full article  | 评论关闭

 

EX:70kg÷(1.75×1.75)=22.86

成人的BMI数值:
过轻:低于18.5
正常:18.5-23.9
过重:24-27
肥胖:28-32
非常肥胖, 高于32
bmi 标准

Read More

json 中文显示乱码

Read full article  | 评论关闭

方法一

print res_content.decode(‘raw_unicode_escape’)

 

方法二

print json.dumps(json.loads(result),ensure_ascii=False)

Read More

http cache

Read full article  | 评论关闭

 

 

Last-Modified  &  ETag  (判断是否修改)

Cache-Control & Expires  (缓存多久)

Read More

AWS RDS 跨区域同步

Read full article  | 评论关闭

 

CALL mysql.rds_set_external_master (‘mymasterserver.mydomain.com’, 3306, ‘repl_user’, ‘<password>’, ‘mysql-bin-changelog.000031′, 107, 0);

CALL mysql.rds_start_replication;

 

Read More

redis key 迁移

Read full article  | 评论关闭

 

当slave, migrate 等方法不能用时,直接用dump/restore

redis-cli  -h cn-vpc-redis-session.aftjvu.0001.cnn1.cache.amazonaws.com.cn -n 1 keys “*”  | while read key  ;do redis-cli -h cn-vpc-redis-session.aftjvu.0001.cnn1.cache.amazonaws.com.cn -n 1 –raw dump $key  | head -c-1 | redis-cli -n 0 -x restore  $key  0 ;done

Read More

json 序列化

Read full article  | 评论关闭

 

 

Json反序列化如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
#coding: utf-8
import json
dict = {'name':'zhangsan', 'age':33, 'address':'红星路'}
print('未序列化前的数据类型为:', type(dict))
print('为序列化前的数据:', dict)
#对dict进行序列化的处理
dict_xu = json.dumps(dict,ensure_ascii=False#添加ensure_ascii=False进行序列化
print('序列化后的数据类型为:', type(dict_xu))
print('序列化后的数据为:', dict_xu)
#对dict_xu进行反序列化处理
dict_fan = json.loads(dict_xu)
print('反序列化后的数据类型为:', type(dict_fan))
print('反序列化后的数据为: ', dict_fan)

Read More

RAP2-delos 添加API参数500错误

Read full article  | 评论关闭

原因是

数据库表Properties中的字段priority, 其属性为int(11)

但传入的数据为:1524666729233   (这个值应该是时间戳)

 

可以将priority的属性调整一下,比如 bigint(50)

 

Read More

GITLAB /var/opt/gitlab/.ssh/authorized_keys 未更新

Read full article  | 评论关闭

 

用户添加public key 后,/var/opt/gitlab/.ssh/authorized_keys 未更新, 重启sidekiq即可!

$ sudo gitlab-ctl kill sidekiq

$ sudo gitlab-ctl start sidekiq

Read More