20413f3f847be098b86bb90b726060fe5650fab3
[nonrtric.git] / test / http-https-proxy / README.md
1 # http proxy
2
3 The http proxy is a generic http proxy which is able to proxy both http and https destination calls.
4 The call to the proxy (to control the proxy call) also supports both http and https (https is using a self signed cert).
5 The main usage for the proxy is as a gateway to all services and pod inside a kubernetest cluster.
6 However, it can be used a basic standard http proxy as well.
7
8 ## Ports and certificates
9
10 The proxy opens the http and https port according to the table below.
11
12 | Port     | Proxy protocol | Usage |
13 | -------- | ------ |----- |
14 | 8080     | http   | Proxy call for http, can proxy both http and https |
15 | 8433     | https  | Proxy call for https, can proxy both http and https |
16 | 8081     | http   | Http port for alive check, returns json with basic statistics |
17 | 8434     | https  | Https port for alive check, returns json with basic statistics |
18
19 The dir cert contains a self-signed cert. Use the script generate_cert_and_key.sh to generate a new certificate and key before building the container, the certs need to be re-generated. If another cert is used, all three files (cert.crt, key.crt and pass) in the cert dir should be mounted to the dir '/usr/src/app/cert' in the container.
20
21 ### Proxy usage
22
23 | Operation | curl example |
24 | --------- | ------------ |
25 | proxy http call via http | curl --proxy <http://localhost:8080> <http://100.110.120.130:1234> |
26 | proxy https call via http | curl -k --proxy <http://localhost:8080> <https://100.110.120.130:5678> |
27 | proxy http call via https | curl --proxy-insecure --proxy <https://localhost:8433> <http://100.110.120.130:1234> |
28 | proxy https call via https | curl --proxy-insecure --proxy <https://localhost:8433> <https://100.110.120.130:5678> |
29 | alive check and get stats | curl localhost:8081 |
30 | alive check and get stats via proxy |  curl --proxy localhost:8080 <http://localhost:8081> |
31
32 ### Build and start
33
34 >Build image<br>
35 ```docker build --build-arg NEXUS_PROXY_REPO=nexus3.onap.org:10001/ -t nodejs-http-proxy:latest .```
36
37 >Start the image on both http and https<br>
38 ```docker run --rm -it -p 8080:8080 -p 8081:8081 -p 8433:8433 -p 8434:8434 nodejs-http-proxy:latest```
39
40 It will listen to http ports 8080/8081 and https ports 8433/8434 (using default certificates) at the same time.
41
42 The script ```proxy-build-start.sh``` do the above two steps in one go. This starts the container in stand-alone mode for basic test.<br>
43
44 ### Basic test
45
46 Basic test is made with the script ```basic_test.sh``` which tests proxy. Use the script ```proxy-build-start.sh``` to start the proxy in a container first.
47
48 ## License
49
50 Copyright (C) 2021 Nordix Foundation. All rights reserved.
51 Licensed under the Apache License, Version 2.0 (the "License");
52 you may not use this file except in compliance with the License.
53 You may obtain a copy of the License at
54
55      http://www.apache.org/licenses/LICENSE-2.0
56
57 Unless required by applicable law or agreed to in writing, software
58 distributed under the License is distributed on an "AS IS" BASIS,
59 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60 See the License for the specific language governing permissions and
61 limitations under the License.