diff --git a/README_CUSTOM_CONFIG.md b/README_CUSTOM_CONFIG.md index 3000c4f..c3b0649 100644 --- a/README_CUSTOM_CONFIG.md +++ b/README_CUSTOM_CONFIG.md @@ -81,4 +81,4 @@ For the first run, this will create a new avd and all the changes will be access Nginx ----- -You can have 1 nginx service to handle multiple containers. Sample nginx configuration is [this](nginx/default) and sample call is ```http://127.0.0.1/container-1/?nginx=&path=/container-1/websockify&view_only=true&password=secr3t``` +Sample nginx configuration can be found [here](nginx/README.md) and sample call is ```http://127.0.0.1/container-1/?nginx=&path=/container-1/websockify&view_only=true&password=secr3t``` diff --git a/nginx/README.md b/nginx/README.md new file mode 100644 index 0000000..5e85db0 --- /dev/null +++ b/nginx/README.md @@ -0,0 +1,15 @@ +Nginx +----- + +You can have one page which contains the list of running container. + +##### Quick Start + +1. Run 2 docker-android container which have port 6081 and 6082 + +2. Run docker nginx + ``` + docker run -d --name nginx --network host -v $PWD/conf.d:/etc/nginx/conf.d nginx:1.18.0 + ``` + +3. Access [http://127.0.0.1](http://127.0.0.1) from Web-Browser to see the list of running containers OR open '''http://127.0.0.1/container-1/?nginx=&path=/container-1/websockify&view_only=true&password=secr3t''' to see specific container. diff --git a/nginx/conf.d/data/data.json b/nginx/conf.d/data/data.json new file mode 100644 index 0000000..4bc1339 --- /dev/null +++ b/nginx/conf.d/data/data.json @@ -0,0 +1,11 @@ +containers = '[\ + {\ + "No": "1", \ + "Name": "Emulator 01", \ + "VNC": "http://127.0.0.1/container-1/?nginx=&path=/container-1/websockify&view_only=true"\ + }, \ + {\ + "No": "2", \ + "Name": "Emulator 02", \ + "VNC": "http://127.0.0.1/container-2/?nginx=&path=/container-2/websockify&view_only=true"\ +}]'; diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100755 index 0000000..a1b527e --- /dev/null +++ b/nginx/conf.d/default.conf @@ -0,0 +1,43 @@ +server { + listen 80; + server_name _; + + location / { + root /etc/nginx/conf.d; + index index.html; + } + + location /container-1/ { + proxy_pass http://127.0.0.1:6081/; + } + + location /container-1/websockify { + proxy_pass http://127.0.0.1:6081/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + # VNC connection timeout + proxy_read_timeout 61s; + + # Disable cache + proxy_buffering off; + } + + location /container-2/ { + proxy_pass http://127.0.0.1:6082/; + } + + location /container-2/websockify { + proxy_pass http://127.0.0.1:6082/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + # VNC connection timeout + proxy_read_timeout 61s; + + # Disable cache + proxy_buffering off; + } +} diff --git a/nginx/conf.d/index.html b/nginx/conf.d/index.html new file mode 100644 index 0000000..fc69a72 --- /dev/null +++ b/nginx/conf.d/index.html @@ -0,0 +1,13 @@ + + +
+ +