From b5c10858ae0742fde9fd81291f2fc5d3279dc67c Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Wed, 7 Feb 2024 23:23:07 +0100 Subject: [PATCH] Add some u-os app spefic stuff --- Dockerfile | 1 - docker-compose.yml | 10 ++-- readme.md | 1 + src/reset.sh | 12 ++++- web/{nginx.conf => nginx.conf.generic} | 0 web/nginx.conf.u-os-app | 64 ++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 7 deletions(-) rename web/{nginx.conf => nginx.conf.generic} (100%) create mode 100644 web/nginx.conf.u-os-app diff --git a/Dockerfile b/Dockerfile index 013abd6..4b0ce49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,6 @@ COPY ./web /var/www/ COPY ./openwrt_additional /var/vm/openwrt_additional RUN chmod +x /run/*.sh -RUN mv /var/www/nginx.conf /etc/nginx/http.d/web.conf VOLUME /storage EXPOSE 8006 diff --git a/docker-compose.yml b/docker-compose.yml index f89c0cc..6b9411b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,8 @@ version: "3" services: qemu: container_name: openwrt - #image: albrechtloh/qemu-openwrt:openwrt-23.05.1-2 - image: "openwrt-docker-arm64" + image: albrechtloh/qemu-openwrt:openwrt-23.05.2-7 + #image: "openwrt-docker-arm64" environment: DEBUG: "y" @@ -19,14 +19,14 @@ services: # USB passthrough # Format : like 'lsusb' is given # Currently only one USB device is supported - #USB_VID_1: "148f" # vendor ID - #USB_PID_1: "7601" # product ID + USB_VID_1: "148f" # vendor ID + USB_PID_1: "7601" # product ID ports: # Port 8006 is console tty web VNC - 8006:8006 # Port 8000 is available only when Docker WAN network is used. - # Use script /root/fw_wan_open_http.sh to open the port + # Use script /usr/bin/fw_wan_open_http.sh to open the port - 8000:8000 stop_grace_period: 2m restart: on-failure diff --git a/readme.md b/readme.md index 8372278..ae0ab72 100644 --- a/readme.md +++ b/readme.md @@ -13,6 +13,7 @@ Images can be found a docker hub https://hub.docker.com/r/albrechtloh/qemu-openw - KVM acceleration - Web-based viewer for tty console - Attaches two physical Ethernet interfaces exclusively into the docker container + - USB passthrough e.g. for modem or Wi-Fi - Automatic config migration when OpenWrt is updated (experimental) ## Usage diff --git a/src/reset.sh b/src/reset.sh index a0ae506..488088e 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -16,11 +16,12 @@ echo # Docker environment variables -: "${CPU_COUNT:=""}" # Physical LAN interface name +: "${CPU_COUNT:=""}" # Physical LAN interface name : "${WAN_IF:=""}" # Physical WAN interface name : "${LAN_IF:=""}" # Physical LAN interface name : "${USB_VID_1:=""}" # USB vendor ID : "${USB_PID_1:=""}" # USB product ID +: "${IS_U_OS_APP:=""}" # By default this container is not a u-OS app : "${DEBUG:="N"}" # Disable debugging # Helper variables @@ -51,6 +52,15 @@ if [ ! -d "$STORAGE" ]; then error "Storage folder ($STORAGE) not found!" && exit 13 fi +# Check u-OS app +if [[ -z "${IS_U_OS_APP}" ]]; then + info "Detected generic container" + cp -f /var/www/nginx.conf.generic /etc/nginx/http.d/web.conf +else + info "Detected u-OS app" + cp -f /var/www/nginx.conf.u-os-app /etc/nginx/http.d/web.conf +fi + # Helper functions isAlive() { diff --git a/web/nginx.conf b/web/nginx.conf.generic similarity index 100% rename from web/nginx.conf rename to web/nginx.conf.generic diff --git a/web/nginx.conf.u-os-app b/web/nginx.conf.u-os-app new file mode 100644 index 0000000..8c638f3 --- /dev/null +++ b/web/nginx.conf.u-os-app @@ -0,0 +1,64 @@ +server { + + listen 80; + listen [::]:80; + listen 8006 default_server; + listen [::]:8006 default_server; + + autoindex on; + tcp_nodelay on; + server_tokens off; + absolute_redirect off; + + error_log /dev/null; + access_log /dev/null; + + include /etc/nginx/mime.types; + + gzip on; + gzip_vary on; + gzip_proxied any; + gzip_comp_level 5; + gzip_min_length 500; + gzip_disable "msie6"; + gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/json application/xml application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml; + + add_header Cache-Control "no-cache"; + + location / { + + root /run/shm; + + if ( -f /run/shm/index.html) { + break; + } + + try_files /index.html @vnc; + } + + location @vnc { + + root /usr/share/novnc; + index vnc.html; + + if ($request_uri = "/") { + return 301 ?resize=scale&autoconnect=true&path=u-os-app-openwrt/websockify; + } + + } + + location /websockify { + + proxy_http_version 1.1; + + proxy_set_header Connection 'upgrade'; + proxy_set_header Upgrade $http_upgrade; + + proxy_buffering off; + proxy_read_timeout 3600s; + proxy_send_timeout 3600s; + + proxy_pass http://127.0.0.1:5700/; + } + +}