Skip to content

Commit

Permalink
Simplified the default configuration file config.json (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanpf authored Oct 31, 2023
1 parent be97ac8 commit ec91842
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 35 deletions.
37 changes: 2 additions & 35 deletions pjs/config.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
{
"Configs": {
"EnableDebug": true,
"ErrorPage": [
{
"Error": [
404
],
"Page": "404.html",
"Directory": "pages/"
},
{
"Error": [
502
],
"Page": "502.html",
"Directory": "pages/"
}
],
"Gzip": {
"GzipMinLength": 1024,
"GzipTypes": [
"text/css",
"text/xml",
"text/html",
"text/plain",
"application/xhtml+xml",
"application/javascript"
]
}
"EnableDebug": false
},
"Listeners": [
{
Expand All @@ -47,7 +20,6 @@
"8080": {
"*": {
"RouteType": "HTTP",
"AccessLog": "/var/log/fgw-access.log",
"Matches": [
{
"Path": {
Expand All @@ -71,11 +43,6 @@
"Index": [
"index.html",
"index.htm"
],
"TryFiles": [
"$uri",
"$uri/default/",
"=404"
]
}
]
Expand Down Expand Up @@ -193,4 +160,4 @@
]
},
"Version": "0"
}
}
169 changes: 169 additions & 0 deletions tests/shpec/config/tls-upstream_shpec/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"Configs": {
"EnableDebug": true
},
"Certificate": {
"CertChain": "-----BEGIN CERTIFICATE-----\nMIIFEjCCAvqgAwIBAgIUKDre1bsG88s52KBVSHKE4bbkDLkwDQYJKoZIhvcNAQEL\nBQAwPDEUMBIGA1UECwwLTXlSb290Q0EgUjIxETAPBgNVBAoMCE15Um9vdENBMREw\nDwYDVQQDDAhNeVJvb3RDQTAeFw0yMjA4MDIwNzA1MzJaFw0zMjA3MzAwNzA1MzJa\nMDUxCzAJBgNVBAYTAkNOMRIwEAYDVQQKDAlNeUludGVyQ0ExEjAQBgNVBAMMCU15\nSW50ZXJDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMCl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nLLBdAp5uigwjR1e/eg2WxKtE8eTIkThaeWIHRpjngryDCKNctONZ\nL93ARMxpenag2r4uD4fZahpspf8LhwExOpcG0HjNb74YVXuylS2IJ6tENsmOPQu/\n2gyYEXhEeHBbc7M5GPv765Xctg/EWPoygl5+MwAhDgsCubwB8Dap5ciuh0fK03fs\nIhRvf3KD2ng8o/ZTJQ51jSvuuzP0oHHp/DYIadg=\n-----END CERTIFICATE-----\n"
},
"Listeners": [
{
"Protocol": "HTTP",
"Port": 8080
},
{
"Protocol": "HTTPS",
"Port": 8081,
"TLS": {
"TLSModeType": "Terminate",
"MTLS": false,
"Certificates": []
}
},
{
"Protocol": "HTTPS",
"Port": 8082,
"TLS": {
"TLSModeType": "Terminate",
"MTLS": false,
"Certificates": []
}
}
],
"RouteRules": {
"8080": {
"*": {
"RouteType": "HTTP",
"Matches": [
{
"Path": {
"Type": "Prefix",
"Path": "/"
},
"BackendService": {
"backendService1": {
"Weight": 100
}
}
}
]
}
},
"8081": {
"*": {
"Matches": [
{
"ServerRoot": "/var/www/html",
"Index": [
"index.html",
"index.htm"
],
"TryFiles": [
"$uri",
"$uri/default/",
"=404"
]
}
]
}
},
"8082": {
"*": {
"Matches": [
{
"ServerRoot": "www2",
"Index": [
"default.html",
"index.html"
]
}
]
}
}
},
"Services": {
"backendService1": {
"Endpoints": {
"127.0.0.1:8081": {
"Weight": 50,
"UseSSL": true
},
"127.0.0.1:8082": {
"Weight": 50,
"UseSSL": true
}
}
}
},
"Chains": {
"HTTPRoute": [
"common/access-control.js",
"common/ratelimit.js",
"common/consumer.js",
"http/codec.js",
"http/access-log.js",
"http/auth.js",
"http/route.js",
"http/fault-injection.js",
"filter/request-redirect.js",
"filter/header-modifier.js",
"filter/url-rewrite.js",
"http/service.js",
"http/metrics.js",
"http/tracing.js",
"http/logging.js",
"http/circuit-breaker.js",
"http/throttle-domain.js",
"http/throttle-route.js",
"http/error-page.js",
"http/proxy-redirect.js",
"http/forward.js",
"http/default.js"
],
"HTTPSRoute": [
"common/access-control.js",
"common/ratelimit.js",
"common/tls-termination.js",
"common/consumer.js",
"http/codec.js",
"http/access-log.js",
"http/auth.js",
"http/route.js",
"http/fault-injection.js",
"filter/request-redirect.js",
"filter/header-modifier.js",
"filter/url-rewrite.js",
"http/service.js",
"http/metrics.js",
"http/tracing.js",
"http/logging.js",
"http/circuit-breaker.js",
"http/throttle-domain.js",
"http/throttle-route.js",
"http/error-page.js",
"http/proxy-redirect.js",
"http/forward.js",
"http/default.js"
],
"TLSPassthrough": [
"common/access-control.js",
"common/ratelimit.js",
"tls/passthrough.js",
"common/consumer.js"
],
"TLSTerminate": [
"common/access-control.js",
"common/ratelimit.js",
"common/tls-termination.js",
"common/consumer.js",
"tls/forward.js"
],
"TCPRoute": [
"common/access-control.js",
"common/ratelimit.js",
"tcp/forward.js"
]
},
"Version": "0"
}
57 changes: 57 additions & 0 deletions tests/shpec/shell/tls-upstream_shpec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

### header ###
export main=`ps aux | grep pipy | grep " --admin-port=12300" | grep -v grep | awk '{print $2}'`
if ! [ "x$main" = "x" ]; then
kill -9 "$main" > /dev/null
fi
# kill -SIGINT $pipypid
export pipy=`ps aux | grep pipy | grep " --admin-port=12301" | grep -v grep | awk '{print $2}'`
if ! [ "x$pipy" = "x" ]; then
kill -9 "$pipy" > /dev/null
fi

export name=`echo "$BASH_SOURCE" | awk -F "[./]" '{print $4}'`

if test -f "config/$name/main.js"; then
(pipy "config/$name/main.js" --admin-port=12300 >/dev/null 2>&1 &)
fi

cp -f "config/$name/config.json" pjs/
(pipy pjs/main.js --admin-port=12301 >tmp/pipy.log 2>&1 &)
for i in {1..10}
do
cat tmp/pipy.log 2>&1 | grep "Thread 0 started" >/dev/null
if ! [ $? -eq 0 ]; then
sleep 0.5
else
break
fi
done

### shell ###

describe "SHPEC TLS upstream (UseSSL) Test"
start="$(date +%s%3N)"
curl -s -i http://127.0.0.1:8080/ > tmp/1.log
output_1="$(cat tmp/1.log)"
end="$(date +%s%3N)"
runtime=$((end-start))

it "Status: 200 OK"
assert grep "$output_1" "200 OK"
end

end

### footer ###

export main=`ps aux | grep pipy | grep " --admin-port=12300" | grep -v grep | awk '{print $2}'`
if ! [ "x$main" = "x" ]; then
kill -9 "$main" > /dev/null
fi
# kill -SIGINT $pipypid
export pipy=`ps aux | grep pipy | grep " --admin-port=12301" | grep -v grep | awk '{print $2}'`
if ! [ "x$pipy" = "x" ]; then
kill -9 "$pipy" > /dev/null
fi

0 comments on commit ec91842

Please sign in to comment.