This is an automated email from the ASF dual-hosted git repository.
kvn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-docker.git
The following commit(s) were added to refs/heads/master by this push:
new a41eb72 feat: use nginx as upstream in the example of docker-compose
(#112)
a41eb72 is described below
commit a41eb72d14a758fca4f0da1c8a7500d85219cc1a
Author: kv <[email protected]>
AuthorDate: Mon Jan 4 10:54:10 2021 +0800
feat: use nginx as upstream in the example of docker-compose (#112)
* feat: use nginx as upstream in the example of docker-compose
* fix: lint failed
* fix: use nginx offical image
* fix: use nginx offical image
* fix: add line break
* chore: add nginx image tag nginx:1.18.0-alpine
---
example/README.md | 26 ++++++--------------------
example/docker-compose-alpine.yml | 18 ++++++++++++------
example/docker-compose.yml | 18 ++++++++++++------
example/upstream/web1.conf | 24 ++++++++++++++++++++++++
example/upstream/web2.conf | 24 ++++++++++++++++++++++++
5 files changed, 78 insertions(+), 32 deletions(-)
diff --git a/example/README.md b/example/README.md
index bf54b6d..ef9fdab 100644
--- a/example/README.md
+++ b/example/README.md
@@ -1,3 +1,5 @@
+**This example is used for functional verification and is not recommended for
performance testing. For performance testing, please refer to
[benchmark](https://github.com/apache/apisix#benchmark) .**
+
### Run
```
@@ -12,7 +14,7 @@ curl http://127.0.0.1:9080/apisix/admin/services/1 -H
'X-API-KEY: edd1c9f034335f
"upstream": {
"type": "roundrobin",
"nodes": {
- "172.18.5.12:8000": 1
+ "172.18.5.12:80": 1
}
}
}'
@@ -22,18 +24,11 @@ curl http://127.0.0.1:9080/apisix/admin/services/2 -H
'X-API-KEY: edd1c9f034335f
"upstream": {
"type": "roundrobin",
"nodes": {
- "172.18.5.13:8000": 1
+ "172.18.5.13:80": 1
}
}
}'
-curl http://127.0.0.1:9080/apisix/admin/routes/11 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
-{
- "uri": "/",
- "host": "web1.lvh.me",
- "service_id": "1"
-}'
-
curl http://127.0.0.1:9080/apisix/admin/routes/12 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/*",
@@ -41,13 +36,6 @@ curl http://127.0.0.1:9080/apisix/admin/routes/12 -H
'X-API-KEY: edd1c9f034335f1
"service_id": "1"
}'
-curl http://127.0.0.1:9080/apisix/admin/routes/21 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
-{
- "uri": "/",
- "host": "web2.lvh.me",
- "service_id": "2"
-}'
-
curl http://127.0.0.1:9080/apisix/admin/routes/22 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/*",
@@ -76,11 +64,9 @@ When testing subdomains, using localhost is not a good
option. Due to this, lets
free service to resolve itself along with all subdomains to localhost.
```
-curl http://web1.lvh.me:9080/ -v # web1.txt
-curl http://web1.lvh.me:9080/web1.txt -v # web1
+curl http://web1.lvh.me:9080/hello -v # hello web1
-curl http://web2.lvh.me:9080/ -v # web2.txt
-curl http://web2.lvh.me:9080/web2.txt -v # web2
+curl http://web2.lvh.me:9080/hello -v # hello web2
```
```
diff --git a/example/docker-compose-alpine.yml
b/example/docker-compose-alpine.yml
index e3fa700..9e30c3b 100644
--- a/example/docker-compose-alpine.yml
+++ b/example/docker-compose-alpine.yml
@@ -39,21 +39,27 @@ services:
ipv4_address: 172.18.5.10
web1:
- image: ruby:2-alpine
- command: sh -c "mkdir -p /tmp/www && echo 'web1' > /tmp/www/web1.txt &&
ruby -run -ehttpd /tmp/www -p8000"
+ image: nginx:1.18.0-alpine
restart: always
+ volumes:
+ - ./upstream/web1.conf:/etc/nginx/nginx.conf
ports:
- - "9081:8000/tcp"
+ - "9081:80/tcp"
+ environment:
+ - NGINX_PORT=80
networks:
apisix:
ipv4_address: 172.18.5.12
web2:
- image: ruby:2-alpine
- command: sh -c "mkdir -p /tmp/www && echo 'web2' > /tmp/www/web2.txt &&
ruby -run -ehttpd /tmp/www -p8000"
+ image: nginx:1.18.0-alpine
restart: always
+ volumes:
+ - ./upstream/web2.conf:/etc/nginx/nginx.conf
ports:
- - "9082:8000/tcp"
+ - "9082:80/tcp"
+ environment:
+ - NGINX_PORT=80
networks:
apisix:
ipv4_address: 172.18.5.13
diff --git a/example/docker-compose.yml b/example/docker-compose.yml
index a6f73d1..5334871 100644
--- a/example/docker-compose.yml
+++ b/example/docker-compose.yml
@@ -36,21 +36,27 @@ services:
ipv4_address: 172.18.5.10
web1:
- image: ruby:2-alpine
- command: sh -c "mkdir -p /tmp/www && echo 'web1' > /tmp/www/web1.txt &&
ruby -run -ehttpd /tmp/www -p8000"
+ image: nginx:1.18.0-alpine
restart: always
+ volumes:
+ - ./upstream/web1.conf:/etc/nginx/nginx.conf
ports:
- - "9081:8000/tcp"
+ - "9081:80/tcp"
+ environment:
+ - NGINX_PORT=80
networks:
apisix:
ipv4_address: 172.18.5.12
web2:
- image: ruby:2-alpine
- command: sh -c "mkdir -p /tmp/www && echo 'web2' > /tmp/www/web2.txt &&
ruby -run -ehttpd /tmp/www -p8000"
+ image: nginx:1.18.0-alpine
restart: always
+ volumes:
+ - ./upstream/web2.conf:/etc/nginx/nginx.conf
ports:
- - "9082:8000/tcp"
+ - "9082:80/tcp"
+ environment:
+ - NGINX_PORT=80
networks:
apisix:
ipv4_address: 172.18.5.13
diff --git a/example/upstream/web1.conf b/example/upstream/web1.conf
new file mode 100644
index 0000000..6a55e50
--- /dev/null
+++ b/example/upstream/web1.conf
@@ -0,0 +1,24 @@
+worker_processes 1;
+error_log stderr notice;
+events {
+ worker_connections 1024;
+}
+
+http {
+ variables_hash_max_size 1024;
+ access_log off;
+ real_ip_header X-Real-IP;
+ charset utf-8;
+
+ server {
+ listen 80;
+
+ location / {
+ return 200 "hello web1";
+ }
+
+ location /static/ {
+ alias static/;
+ }
+ }
+}
diff --git a/example/upstream/web2.conf b/example/upstream/web2.conf
new file mode 100644
index 0000000..7501d72
--- /dev/null
+++ b/example/upstream/web2.conf
@@ -0,0 +1,24 @@
+worker_processes 1;
+error_log stderr notice;
+events {
+ worker_connections 1024;
+}
+
+http {
+ variables_hash_max_size 1024;
+ access_log off;
+ real_ip_header X-Real-IP;
+ charset utf-8;
+
+ server {
+ listen 80;
+
+ location / {
+ return 200 "hello web2";
+ }
+
+ location /static/ {
+ alias static/;
+ }
+ }
+}