From 4aa994e59fc07eaf428cace5f47f2aba68ab9855 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 24 May 2022 17:56:31 +0200 Subject: [PATCH] ingress addition --- photoprism/CHANGELOG.md | 2 + photoprism/config.json | 8 +-- .../etc/cont-init.d/32-nginx_ingress.sh | 15 ++++++ photoprism/rootfs/etc/cont-init.d/99-run.sh | 4 +- .../rootfs/etc/nginx/servers/ingress.conf | 49 +++++++++++++++++++ 5 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 photoprism/rootfs/etc/nginx/servers/ingress.conf diff --git a/photoprism/CHANGELOG.md b/photoprism/CHANGELOG.md index c82364117..3c8aee369 100644 --- a/photoprism/CHANGELOG.md +++ b/photoprism/CHANGELOG.md @@ -1,5 +1,7 @@ +- Feat: ingress implementation. Bug : don't click on refresh (click cancel) ## 220517-jammy (19-05-2022) + - Update to latest version from photoprism/photoprism - Implementation of ssl - Add codenotary sign diff --git a/photoprism/config.json b/photoprism/config.json index a776000fe..f1f3c55f0 100644 --- a/photoprism/config.json +++ b/photoprism/config.json @@ -43,6 +43,8 @@ "working_dir": "/data/photoprism" }, "homeassistant": "0.92.0b2", + "ingress": true, + "ingress_stream": true, "map": [ "media:rw", "share:rw", @@ -62,6 +64,7 @@ "keyfile": "privkey.pem", "ssl": false }, + "panel_icon": "mdi:camera", "ports": { "2342/tcp": 2342 }, @@ -93,6 +96,5 @@ ], "slug": "photoprism", "url": "https://github.com/alexbelgium/hassio-addons-test", - "version": "220517-3", - "webui": "[PROTO:ssl]://[HOST]:[PORT:2342]" -} + "version": "220517-2" +} \ No newline at end of file diff --git a/photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..f307cd7af --- /dev/null +++ b/photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,15 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare ingress_interface +declare ingress_port + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +ingress_entry=$(bashio::addon.ingress_entry) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf +sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/nginx/servers/ingress.conf diff --git a/photoprism/rootfs/etc/cont-init.d/99-run.sh b/photoprism/rootfs/etc/cont-init.d/99-run.sh index 8620c6cf6..b7de9e262 100644 --- a/photoprism/rootfs/etc/cont-init.d/99-run.sh +++ b/photoprism/rootfs/etc/cont-init.d/99-run.sh @@ -84,6 +84,8 @@ bashio::log.info "Please wait 1 or 2 minutes to allow the server to load" bashio::log.info 'Default username : admin, default password: "please_change_password"' cd / -./scripts/entrypoint.sh photoprism start & bashio::log.info "App launched..." +./scripts/entrypoint.sh photoprism start & bashio::log.info "Starting..." + +bashio::net.wait_for 2341 localhost 900 bashio::log.info "App launched..." exec nginx diff --git a/photoprism/rootfs/etc/nginx/servers/ingress.conf b/photoprism/rootfs/etc/nginx/servers/ingress.conf new file mode 100644 index 000000000..85383ecec --- /dev/null +++ b/photoprism/rootfs/etc/nginx/servers/ingress.conf @@ -0,0 +1,49 @@ +server { + listen %%interface%%:%%port%% default_server; + include /etc/nginx/includes/server_params.conf; + include /etc/nginx/includes/proxy_params.conf; + client_max_body_size 0; + server_name photoprism.*; + + location / { + + proxy_pass http://127.0.0.1:2341; + + # Websockets + proxy_http_version 1.1; + proxy_set_header Connection "upgrade"; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Host $host; + + # Rewrite url + sub_filter_types *; + sub_filter "/manifest.json" "%%ingress_entry%%/manifest.json"; + sub_filter "/browse" "%%ingress_entry%%/browse"; + sub_filter "/static" "%%ingress_entry%%/static"; + sub_filter "/auth" "%%ingress_entry%%/auth"; + sub_filter "/api" "%%ingress_entry%%/api"; + sub_filter "/albums" "%%ingress_entry%%/albums"; + sub_filter "/videos" "%%ingress_entry%%/videos"; + sub_filter "/people" "%%ingress_entry%%/people"; + sub_filter "/favorites" "%%ingress_entry%%/favorites"; + sub_filter "/moments" "%%ingress_entry%%/moments"; + sub_filter "/calendar" "%%ingress_entry%%/calendar"; + sub_filter "/places" "%%ingress_entry%%/places"; + sub_filter "/labels" "%%ingress_entry%%/labels"; + sub_filter "/folders" "%%ingress_entry%%/folders"; + sub_filter "/private" "%%ingress_entry%%/private"; + sub_filter "/library" "%%ingress_entry%%/library"; + sub_filter "/settings" "%%ingress_entry%%/settings"; + sub_filter_once off; + proxy_buffering off; + proxy_read_timeout 30; + + # Allow frames + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_hide_header "Content-Security-Policy"; + add_header X-Frame-Options SAMEORIGIN; + add_header Access-Control-Allow-Origin *; + proxy_set_header Accept-Encoding ""; + } +} +