Commit 57d39ae1 authored by vicotor's avatar vicotor

Merge branch 'peer' into 'master'

Merge latest content to master.

See merge request !1
parents b0b1cf13 89884e62
......@@ -13,22 +13,14 @@ services:
volumes:
- ./cryptor/config.toml:/root/config.toml
sender:
image: caduceus/cmp2-test-net-tester:v0.0.12-7
image: caduceus/cmp2-test-net-tester:v0.0.12-16
container_name: sender
entrypoint: sh -c 'echo +sender+ && sender -test.run TestManyToMany /privatefromto-100_000.tmp 192.168.1.220 cryptor-sender 1000 0 5000 >> /sender/sender.log 2>&1 '
entrypoint: sh -c 'echo +sender+ && sender -test.run TestManyToMany /privatefromto-100_000.tmp 192.168.1.220 cryptor-sender 10000 0 50000 >> /sender/sender.log 2>&1 '
#entrypoint: sh -c 'sender -test.run TestManyToMany -test.timeout 0 /privatefromto-10_000.tmp 192.168.1.220 cryptor-sender 30000'
#echo " entrypoint: sh -c 'echo "+"ring"+" && sleep 10 && sender -test.run TestManyToMany -test.timeout 0 "
#entrypoint: sh -c 'echo "sender" && sleep 40 && go test -v -run TestSendSignatureTxsStream ./rpc/grpc/ --timeout 0 -args ring 192.168.1.242 100000'
ports:
- "2115:2115"
deploy:
resources:
limits:
cpus: "36.00"
memory: 32G
reservations:
cpus: "30.00"
memory: 32G
volumes:
- ./sender/sender:/sender/
depends_on:
......@@ -37,7 +29,7 @@ services:
image: google/cadvisor:latest
container_name: cadvisor-sender
ports:
- "8080:8080"
- "8081:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
......
{
"rpcURL": "http://192.168.1.220:18545"
}
......@@ -4,106 +4,153 @@ set -e
isSeed=0
withParam=0
input_string_ip=""
input_string_enr=""
input_string_my_ip=""
input_string_connected_ip=""
input_string_static_peer=""
if [ $# -eq 2 ]; then
if [ $# -eq 3 ]; then
withParam=1
isSeed=1
datadir=${1:-./data/}
input_string_ip=${2}
input_string_my_ip=${2}
regex='^([0-9]{1,3}\.){3}[0-9]{1,3}$'
while true
do
if [[ $input_string_ip =~ $regex ]]; then
if [[ $input_string_my_ip =~ $regex ]]; then
break
fi
echo ${input_string_ip}" is not a valid ip"
echo "please input your p2p public ip address as seed: "
read input_string_ip
echo ${input_string_my_ip}" is not a valid my ip"
echo "please input your p2p public ip address as peer: "
read input_string_my_ip
done
input_string_connected_ip=${3}
while true
do
if [[ $input_string_connected_ip =~ $regex ]]; then
break
fi
echo ${input_string_connected_ip}" is not a valid connected ip"
echo "please input your p2p public ip address as connected ip: "
read input_string_connected_ip
done
fi
if [ $# -eq 3 ]; then
if [ $# -eq 4 ]; then
withParam=1
datadir=${1:-./data/}
input_string_ip=${2}
input_string_enr=${3}
input_string_my_ip=${2}
input_string_connected_ip=${3}
input_string_static_peer=${4}
regex='^([0-9]{1,3}\.){3}[0-9]{1,3}$'
while true
do
if [[ $input_string_ip =~ $regex ]]; then
if [[ $input_string_my_ip =~ $regex ]]; then
break
fi
echo ${input_string_ip}" is not a valid ip"
echo "please input your p2p public ip address as seed: "
read input_string_ip
echo ${input_string_my_ip}" is not a valid my ip"
echo "please input your p2p public ip address as my service ip: "
read input_string_my_ip
done
while true
do
if [ $(echo ${input_string_enr} | wc -L) -eq 200 ] ; then
if [[ $input_string_connected_ip =~ $regex ]]; then
break
fi
echo ${input_string_enr}" is not a valid seed enr"
echo "please input your p2p seed enr: "
read input_string_enr
echo ${input_string_connected_ip}" is not a valid connected ip"
echo "please input your connected sentry public ip address:"
read input_string_connected_ip
done
fi
if [ $withParam -eq 0 ]; then
while true
do
break
echo "peer----------------"
echo ${input_string_static_peer##*/}
echo ${input_string_static_peer##*/} | wc -L
read -p "please input your data dir:" datadir
datadir=${datadir:-./data/}
while true
do
echo "please input your p2p public ip address as seed: "
read input_string_ip
if [[ $input_string_ip =~ $regex ]]; then
if [ $(echo ${input_string_static_peer##*/} | wc -L) -eq 53 ] ; then
break
fi
echo ${input_string_ip}" is not a valid ip"
echo "please input your p2p public ip address as seed: "
read input_string_ip
done
echo ${input_string_static_peer}" is not a valid peer id"
echo "please input your p2p peer id: "
read input_string_static_peer
done
fi
while true
do
echo "please input your p2p seed enr, or cancel with no: "
read input_string_enr
if [ $(echo ${input_string_enr} | wc -L) -eq 200 ] ; then
break
fi
if [ ${input_string_enr} == "no" ]; then
isSeed=1
break
fi
echo ${input_string_enr}" is not a valid seed enr"
echo "please input your p2p seed enr: "
read input_string_enr
done
if [ $withParam -eq 0 ]; then
fi
echo "please run the cmd with parameter "
echo ""
echo "run the node as seed"
echo "./host.sh /datadir myIpAsP2pSeed connectedSentryIp"
echo "run the node as normal node"
echo "./host.sh /datadir myIpAsP2pSeed connectedSentryIp connectedPeerId"
echo "isSeed " $isSeed
echo "withParam " $withParam
echo "input_string_ip " $input_string_ip
echo "input_string_enr " $input_string_enr
# read -p "please input your data dir:" datadir
# datadir=${datadir:-./data/}
# while true
# do
# echo "please input your p2p public ip address as seed: "
# read input_string_ip
# if [[ $input_string_ip =~ $regex ]]; then
# break
# fi
# echo ${input_string_ip}" is not a valid ip"
# echo "please input your p2p public ip address as seed: "
# read input_string_ip
# done
# while true
# do
# echo "please input your p2p peer id, or cancel with no: "
# read input_string_enr
# echo "peer----------------"
# echo ${input_string_enr##*/}
# echo ${input_string_enr##*/} | wc -L
# if [ $(echo ${input_string_enr##*/} | wc -L) -eq 53 ] ; then
# break
# fi
# # if [ $(echo ${input_string_enr} | wc -L) -eq 200 ] ; then
# # break
# # fi
# if [ ${input_string_enr} == "no" ]; then
# isSeed=1
# break
# fi
# echo ${input_string_enr}" is not a valid seed enr"
# echo "please input your p2p seed enr: "
# read input_string_enr
# done
seedEnr=$input_string_enr
ipAddr=$input_string_ip
fi
echo "isSeed " $isSeed
echo "withParam " $withParam
echo "input_string_my_ip " $input_string_my_ip
echo "input_string_connected_ip " $input_string_connected_ip
echo "input_string_static_peer " $input_string_static_peer
staticPeer=$input_string_static_peer
myIpAddr=$input_string_my_ip
connectedSentryIp=$input_string_connected_ip
......@@ -149,6 +196,15 @@ echo 'max_gs_count = 50000000' >> $configFile
echo 'gs_block_count = 100' >> $configFile
echo "{" > ./explorer/config.json
echo " \"rpcURL\": \"http://$myIpAddr:18545\"" >> ./explorer/config.json
echo "}" >> ./explorer/config.json
sed "s/EXPORT_IP/$myIpAddr/g" ./nginx/conf.d/ethnode.conf.temp > /tmp/ethnode.conf.a
sed "s/LOCAL_IP/$connectedSentryIp/g" /tmp/ethnode.conf.a > ./nginx/conf.d/ethnode.conf
rm -f /tmp/ethnode.conf.a
# net config
for i in $(seq 1 $N)
do
......@@ -161,19 +217,29 @@ do
echo "single-node: true" >> $configFile
echo "log-level: \"debug\"" >> $configFile
echo "enable-prom: true" >> $configFile
echo "use-discovery: true" >> $configFile
echo "use-discovery: false" >> $configFile
echo "nebula-grpc-address: \"nebula:38004\"" >> $configFile
echo "grpc-host: \"0.0.0.0\"" >> $configFile
echo "grpc-port: 38010" >> $configFile
echo "p2p-host-ip: \"$ipAddr\"" >> $configFile
if [ $i -eq 1 ]; then
echo "p2p-priv-key: \"/etc/MetaNet/default-priv-key\"" >> $configFile
else
echo "bootstrap-node: [${seedEnr}]" >> $configFile
#echo "bootstrap-node: [\"enr:-JG4QEOwrARSiElnvYO0oWjgOrt9-faERbU0O_pYM2Cuh_s9K__lZ2Lco569gWZFfOrqI7pEwKBxG3RYqZRvhJCHwMGGAYvHpaQegmlkgnY0gmlwhBJmI8iJc2VjcDI1NmsxoQJ81pyuyqa2QoPztOPsCqpkcW1gJwUxOcSJuWr9VUNavIN0Y3CCdn2DdWRwgnZ-\"]" >> $configFile
echo "p2p-host-ip: \"$myIpAddr\"" >> $configFile
private_key=$(openssl rand -hex 32)
echo -n $private_key > $configPath/private-key
echo "p2p-priv-key: \"/root/private-key\"" >> $configFile
echo "generate net $i private key $private_key"
if [ $i -ne 1 ]; then
echo "peer: [\"${staticPeer}\"]" >> $configFile
fi
# echo "peer: \"$ipAddr\"" >> $configFile
# peer: ["要连接的peerid"]
# if [ $i -eq 1 ]; then
# echo "p2p-priv-key: \"/etc/MetaNet/default-priv-key\"" >> $configFile
# else
# echo "bootstrap-node: [${seedEnr}]" >> $configFile
# fi
done
# net config end
#echo "bootstrap-node: [\"enr:-JG4QEOwrARSiElnvYO0oWjgOrt9-faERbU0O_pYM2Cuh_s9K__lZ2Lco569gWZFfOrqI7pEwKBxG3RYqZRvhJCHwMGGAYvHpaQegmlkgnY0gmlwhBJmI8iJc2VjcDI1NmsxoQJ81pyuyqa2QoPztOPsCqpkcW1gJwUxOcSJuWr9VUNavIN0Y3CCdn2DdWRwgnZ-\"]" >> $configFile
......@@ -271,7 +337,7 @@ sentryConfig="app.json"
echo "{" > $sentryConfig
echo "\"contract\": \"0x054795542cA35Fb055b219ed647628935e5dDf96\"," >> $sentryConfig
echo "\"rpc_node\": \"http://$ipAddr:8545\"," >> $sentryConfig
echo "\"rpc_node\": \"http://$connectedSentryIp:8545\"," >> $sentryConfig
echo "\"chain_id\": 1024," >> $sentryConfig
echo "\"main_account_priv\": \"F53D987FB2E98107A6AD7916AA8C6FF65F9C19D3F703AF7540002357ECAB69A1\"" >> $sentryConfig
echo "}" >> $sentryConfig
......@@ -300,6 +366,46 @@ echo "sleep 10" >> $startfile
fi
echo "docker compose -f "$composefile" up -d" >> $startfile
# while [ ! -e "$file_path" ]; do
# echo "文件不存在,等待中..."
# sleep 1 # 可以调整等待的时间间隔,单位为秒
#done
echo "while [ ! -e $datadir/net/$i/peer-id ];do" >> $startfile
echo " echo \"waiting for $i peer-id\"">> $startfile
echo " sleep 1" >> $startfile
echo "done" >> $startfile
echo "ip=\$(cat $datadir/net/$i/config.yaml | grep "p2p-host-ip"| grep -o '\".*\"' | sed 's/[\"\"]//g') " >> $startfile
#echo "echo \$ip" >> $startfile
echo "peerid=\$(cat $datadir/net/$i/peer-id)" >> $startfile
#echo "echo \$peerid" >> $startfile
echo "sentryIp=\$(cat $datadir/sentry/app.json | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')" >> $startfile
echo "echo ./host.sh ./dir replaceCunnentNodePublicIP \$sentryIp /ip4/\$ip/tcp/30333/p2p/\$peerid" >> $startfile
echo "for i in {1..120}" >> $startfile
echo "do" >> $startfile
echo " echo -ne \">\" " >> $startfile
echo "done " >> $startfile
echo " echo \"\" " >> $startfile
echo " echo \"\" " >> $startfile
echo "for i in {1..120}" >> $startfile
echo "do" >> $startfile
echo " echo -ne \">\" " >> $startfile
echo " sleep 1" >> $startfile
echo "done " >> $startfile
echo " echo \"\" " >> $startfile
chmod +x $startfile
......@@ -320,9 +426,7 @@ chmod +x $stopfile
echo 'version: "3.9"' > $composefile
echo '' >> $composefile
echo 'services:' >> $composefile
echo "" >> $composefile
echo "" >> $composefile
echo '' >> $composefile
echo " cryptor:" >> $composefile
echo ' image: caduceus/cmp2-test-net-meta-crypto:v0.0.1 ' >> $composefile
echo " container_name: cryptor" >> $composefile
......@@ -375,30 +479,33 @@ echo "" >> $composefile
echo " nebula:" >> $composefile
echo " image: caduceus/cmp2-test-net-meta-nebula:v0.0.15" >> $composefile
echo " container_name: nebula" >> $composefile
echo " volumes:" >> $composefile
echo " - "$datadir"/nebula/:/root" >> $composefile
echo " depends_on:" >> $composefile
echo " - net" >> $composefile
echo " - sentry" >> $composefile
echo "$resourcenebula" >> $composefile
echo " ports:" >> $composefile
echo " - $((38004)):38004" >> $composefile
echo " - $((28000)):28080" >> $composefile
echo " networks:" >> $composefile
echo " - meta" >> $composefile
echo "" >> $composefile
# if [ $i -eq 1 ]; then
# #echo "p2p-priv-key: \"/etc/MetaNet/default-priv-key\"" >> $configFile
# echo "" >> $composefile
# else
echo " nebula:" >> $composefile
echo " image: caduceus/cmp2-test-net-meta-nebula:v0.0.20" >> $composefile
echo " container_name: nebula" >> $composefile
echo " volumes:" >> $composefile
echo " - "$datadir"/nebula/:/root" >> $composefile
echo " depends_on:" >> $composefile
echo " - net" >> $composefile
echo " - sentry" >> $composefile
echo "$resourcenebula" >> $composefile
echo " ports:" >> $composefile
echo " - $((38004)):38004" >> $composefile
echo " - $((28000)):28080" >> $composefile
echo " networks:" >> $composefile
echo " - meta" >> $composefile
echo "" >> $composefile
#fi
echo " ring:" >> $composefile
echo " image: caduceus/cmp2-test-net-meta-ring:v0.0.7-6" >> $composefile
echo " image: caduceus/cmp2-test-net-meta-ring:v0.0.7-25" >> $composefile
echo " container_name: ring" >> $composefile
#echo " entrypoint: sh -c 'echo "+"ring"+" && sleep 10 && ringd start --ethconfig.httphost 0.0.0.0 --mempool.sentryurl sentry:38003 --mempool.nebulaurl nebula:38004 --mempool.p2purl net:38010 --mempool.cryptourl cryptor:38001 --mempool.checkerurl txchecker:38002 --mempool.writeunreadytxs=false --mempool.writerepeatedmsg=false --mempool.batchconfirminittimeout=60 --mempool.batchconfirmtimeouti=1.5 --mempool.batchrepeatedqueuesize=0' " >> $composefile
echo " entrypoint: sh -c 'echo "+"ring"+" && sleep 10 && ringd start --ethconfig.httphost 0.0.0.0 --mempool.sentryurl sentry:38003 --mempool.nebulaurl nebula:38004 --mempool.p2purl net:38010 --mempool.cryptourl cryptor:38001 --mempool.checkerurl txchecker:38002 --mempool.writeunreadytxs=false --mempool.writerepeatedmsg=false --mempool.batchconfirminittimeout=600 --mempool.batchconfirmtimeouti=1.5 --mempool.batchrepeatedqueuesize=0 --mempool.batchconfirmenable=false --rpconfig.async=true >>/data/log 2>&1 ' " >> $composefile
echo " entrypoint: sh -c 'echo "+"ring"+" && sleep 50 && ringd start --ethconfig.httphost 0.0.0.0 --mempool.sentryurl sentry:38003 --mempool.nebulaurl nebula:38004 --mempool.p2purl net:38010 --mempool.cryptourl cryptor:38001 --mempool.checkerurl txchecker:38002 --mempool.writeunreadytxs=false --mempool.writerepeatedmsg=false --mempool.batchconfirminittimeout=600 --mempool.batchconfirmtimeouti=1.5 --mempool.batchrepeatedqueuesize=0 --mempool.batchconfirmenable=false --rpconfig.async=true >>/data/log 2>&1 ' " >> $composefile
echo " volumes:" >> $composefile
echo " - "$datadir"/ring/:/data" >> $composefile
echo " depends_on:" >> $composefile
......@@ -407,7 +514,7 @@ echo " - net" >> $composefile
echo " - sentry" >> $composefile
echo "$resourcering" >> $composefile
echo " ports:" >> $composefile
echo " - $((18545)):8545" >> $composefile
echo " - $((28545)):8545" >> $composefile
echo " - $((5001)):5001" >> $composefile
echo " - $((38020)):38020" >> $composefile
echo " - $((6060)):6060" >> $composefile
......@@ -416,7 +523,17 @@ echo " - meta" >> $composefile
echo " explorer:" >> $composefile
echo " image: caduceus/cmp2-node-explorer:v0.0.15" >> $composefile
echo " container_name: explorer" >> $composefile
echo " ports:" >> $composefile
echo " - $((10080)):80" >> $composefile
echo " volumes:" >> $composefile
echo " - ./explorer:/usr/share/nginx/html/config" >> $composefile
echo " networks:" >> $composefile
echo " - meta" >> $composefile
echo " cadvisor:" >> $composefile
......@@ -432,7 +549,10 @@ echo " - /var/lib/docker/:/var/lib/docker:ro" >> $composefile
echo " depends_on:" >> $composefile
echo " - sentry" >> $composefile
echo " - net" >> $composefile
if [ $i -ne 1 ]; then
echo " - nebula" >> $composefile
fi
#echo " - nebula" >> $composefile
echo " - ring" >> $composefile
echo " networks:" >> $composefile
echo " - meta" >> $composefile
......@@ -455,6 +575,19 @@ echo " depends_on:" >>
echo " - cadvisor" >> $composefile
echo " networks:" >> $composefile
echo " - meta" >> $composefile
echo " openresty:" >> $composefile
echo " image: openresty/openresty" >> $composefile
echo " container_name: openresty" >> $composefile
echo " ports:" >> $composefile
echo " - \"80:80\"" >> $composefile
echo " - \"18545:18545\"" >> $composefile
echo " volumes:" >> $composefile
echo " - ./nginx/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf" >> $composefile
echo " - ./nginx/conf.d:/etc/nginx/conf.d" >> $composefile
echo " networks:" >> $composefile
echo " - meta" >> $composefile
echo "networks:" >> $composefile
echo " meta:" >> $composefile
echo " driver: bridge" >> $composefile
......@@ -463,15 +596,7 @@ echo " config:" >>
echo " - subnet: 172.99.0.0/16" >> $composefile
done
done
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
server {
listen 18545;
server_name 13.213.12.100 ;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Max-Age' 1728000;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
proxy_set_header Host $host:$server_port;
proxy_pass http://172.31.42.138:28545;
}
}
server {
listen 80;
server_name REMOTE_IP;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Max-Age' 1728000;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
proxy_set_header Host $host:$server_port;
proxy_pass http://172.31.42.138:10080;
}
}
server {
listen 18545;
server_name EXPORT_IP ;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Max-Age' 1728000;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
proxy_set_header Host $host:$server_port;
proxy_pass http://LOCAL_IP:28545;
}
}
server {
listen 80;
server_name REMOTE_IP;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Max-Age' 1728000;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' '*';
}
proxy_set_header Host $host:$server_port;
proxy_pass http://LOCAL_IP:10080;
}
}
# cat nginx.conf
# nginx.conf -- docker-openresty
#
# This file is installed to:
# `/usr/local/openresty/nginx/conf/nginx.conf`
# and is the file loaded by nginx at startup,
# unless the user specifies otherwise.
#
# It tracks the upstream OpenResty's `nginx.conf`, but removes the `server`
# section and adds this directive:
# `include /etc/nginx/conf.d/*.conf;`
#
# The `docker-openresty` file `nginx.vh.default.conf` is copied to
# `/etc/nginx/conf.d/default.conf`. It contains the `server section
# of the upstream `nginx.conf`.
#
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
#
#user nobody;
worker_processes 4;
worker_rlimit_nofile 65535;
#error_log /var/log/nginx/error.log warn;
#pid /var/run/nginx.pid;
events {
#设置网路连接序列化,防止惊群现象发生,默认为on
accept_mutex on;
#设置一个进程是否同时接受多个网络连接,默认为off
multi_accept on;
#事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
use epoll;
worker_connections 65535;
}
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
#限制请求
limit_req_zone $binary_remote_addr zone=api_read:20m rate=10r/s;
#limit_req_zone $uri zone=api_read:20m rate=100r/s;
#按ip配置一个连接 zone
limit_conn_zone $binary_remote_addr zone=perip_conn:10m;
#按server配置一个连接 zone
limit_conn_zone $server_name zone=perserver_conn:100m;
#指定在当前文件中包含另一个文件的指令
include mime.types;
#指定默认处理的文件类型可以是二进制
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#混淆数据,影响三列冲突率,值越大消耗内存越多,散列key冲突率会降低,检索速度更快;值越小key,占用内存较少,冲突率越高,检索速度变慢
types_hash_max_size 2048;
charset utf-8;
#取消服务日志
#access_log off;
#access_log /var/log/nginx/access.log main;
#每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。
sendfile_max_chunk 51200m;
sendfile on;
#单连接请求上限次数。
keepalive_requests 1200;
#让nginx在一个数据包中发送所有的头文件,而不是一个一个单独发
tcp_nopush on;
#nginx不要缓存数据,而是一段一段发送,如果数据的传输有实时性的要求的话可以配置它,发送完一小段数据就立刻能得到返回值,但是不要滥用
#tcp_nodelay on;
#设置请求头的超时时间
#client_header_timeout 10;
#设置请求体的超时时间
#client_body_timeout 10;
#指定客户端响应超时时间,如果客户端两次操作间隔超过这个时间,服务器就会关闭这个链接
#send_timeout 10;
#设置用于保存各种key的共享内存的参数
#limit_conn_zone $binary_remote_addr zone=addr:5m;
#给定的key设置最大连接数
#limit_conn addr 100
#虽然不会让nginx执行速度更快,但是可以在错误页面关闭nginx版本提示,对于网站安全性的提升有好处
#server_tokens
# SSL证书配置
#指令用于启动特定的加密协议,nginx在1.1.13和1.0.12版本后默认是ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2,TLSv1.1与TLSv1.2要确保OpenSSL >= 1.0.1
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
#设置协商加密算法时,优先使用我们服务端的加密套件,而不是客户端浏览器的加密套件
#ssl_prefer_server_ciphers on;
#给客户端分配连接超时时间,服务器会在这个时间过后关闭连接。一般设置时间较短,可以让nginx工作持续性更好
keepalive_timeout 65;
# Gzip 压缩配置
gzip on;
#gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
client_body_temp_path /var/run/openresty/nginx-client-body;
proxy_temp_path /var/run/openresty/nginx-proxy;
fastcgi_temp_path /var/run/openresty/nginx-fastcgi;
uwsgi_temp_path /var/run/openresty/nginx-uwsgi;
scgi_temp_path /var/run/openresty/nginx-scgi;
include /etc/nginx/conf.d/*.conf;
}
scrape_configs:
- job_name: cadvisor-sender
scrape_interval: 5s
static_configs:
- targets:
- cadvisor-sender:8080
- job_name: cadvisor
scrape_interval: 5s
static_configs:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment