Added sample config of nginx
This commit is contained in:
parent
b9d6237eb4
commit
9b2bc985e0
|
@ -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```
|
||||
|
|
15
nginx/README.md
Normal file
15
nginx/README.md
Normal file
|
@ -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.
|
11
nginx/conf.d/data/data.json
Normal file
11
nginx/conf.d/data/data.json
Normal file
|
@ -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"\
|
||||
}]';
|
43
nginx/conf.d/default.conf
Executable file
43
nginx/conf.d/default.conf
Executable file
|
@ -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;
|
||||
}
|
||||
}
|
13
nginx/conf.d/index.html
Normal file
13
nginx/conf.d/index.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>List of docker-android containers</title>
|
||||
<link href="styles/main.css" type="text/css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="showData"></div>
|
||||
<script type="text/javascript" src="data/data.json"></script>
|
||||
<script src="scripts/main.js" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
55
nginx/conf.d/scripts/main.js
Normal file
55
nginx/conf.d/scripts/main.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
var devices = JSON.parse(containers);
|
||||
|
||||
var headers = [];
|
||||
for (var pos = 0; pos < devices.length; pos++) {
|
||||
for (var deviceKey in devices[pos]) {
|
||||
// Check if key is already added to headers
|
||||
if (headers.indexOf(deviceKey) === -1) {
|
||||
headers.push(deviceKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a table
|
||||
var table = document.createElement("table");
|
||||
|
||||
// Insert table header
|
||||
var tr = table.insertRow(-1);
|
||||
for (var pos = 0; pos < headers.length; pos++) {
|
||||
var th = document.createElement("th"); // TABLE HEADER.
|
||||
var header = headers[pos];
|
||||
th.innerHTML = header;
|
||||
tr.appendChild(th);
|
||||
}
|
||||
|
||||
// Insert table content
|
||||
for (var pos = 0; pos < devices.length; pos++) {
|
||||
tr = table.insertRow(-1);
|
||||
for (var index = 0; index < headers.length; index++) {
|
||||
var td = document.createElement("td");
|
||||
var content = devices[pos][headers[index]];
|
||||
|
||||
if (index == 1) {
|
||||
var link = document.createElement("a");
|
||||
link.href = devices[pos][headers[index+1]];
|
||||
link.innerHTML = content;
|
||||
td.appendChild(link);
|
||||
} else if (index === 2) {
|
||||
var object = document.createElement("object");
|
||||
object.type = "text/html"
|
||||
object.data = content;
|
||||
object.width = "950px";
|
||||
object.height = "950px";
|
||||
td.appendChild(object);
|
||||
} else {
|
||||
td.innerHTML = content;
|
||||
}
|
||||
|
||||
tr.appendChild(td);
|
||||
}
|
||||
}
|
||||
|
||||
// Put the table inside div
|
||||
var divContainer = document.getElementById("showData");
|
||||
divContainer.innerHTML = "";
|
||||
divContainer.appendChild(table);
|
13
nginx/conf.d/styles/main.css
Normal file
13
nginx/conf.d/styles/main.css
Normal file
|
@ -0,0 +1,13 @@
|
|||
th, td {
|
||||
font:14px Verdana;
|
||||
}
|
||||
table, th, td
|
||||
{
|
||||
border: solid 1px #DDD;
|
||||
border-collapse: collapse;
|
||||
padding: 2px 3px;
|
||||
text-align: center;
|
||||
}
|
||||
th {
|
||||
font-weight:bold;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location /container-1/ {
|
||||
proxy_pass http://127.0.0.1:6080/;
|
||||
}
|
||||
|
||||
location /container-1/websockify {
|
||||
proxy_pass http://127.0.0.1:6080/;
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue