diff --git a/extra/element-web-nginx.conf b/extra/element-web-nginx.conf new file mode 100644 index 0000000..8959c08 --- /dev/null +++ b/extra/element-web-nginx.conf @@ -0,0 +1,70 @@ +server { + listen 8080; + listen [::]:8080; + server_name localhost; + + root /var/empty; + index index.html; + + log_not_found on; + access_log /dev/stderr combined; + error_log /dev/stderr info; + + location /upschooling/element-web { + rewrite ^/upschooling/element-web/(.*)$ /$1 break; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_pass "http://127.0.0.1:8082"; + } + location /.well-known/matrix { + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods GET; + + default_type application/json; + + # TODO: Add missing matrix well-known files + proxy_set_header Host localhost:8008; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_redirect http://localhost:8008/.well-known/matrix http://localhost:8080/.well-known/matrix; + proxy_pass "http://127.0.0.1:8008$uri"; + } + location / { + proxy_set_header Host localhost:8080; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_redirect off; + proxy_pass "http://127.0.0.1:80$uri"; + } +} + +server { + listen 8082; + listen [::]:8082; + server_name localhost; + + root /usr/share/nginx/html; + index index.html; + + set_real_ip_from 127.0.0.1; + set_real_ip_from ::1; + + # Set no-cache for the version, config and index.html + # so that browsers always check for a new copy of Element Web. + # NB http://your-domain/ and http://your-domain/? are also covered by this + + location = /index.html { + add_header Cache-Control "no-cache"; + } + location = /version { + add_header Cache-Control "no-cache"; + } + # covers config.json and config.hostname.json requests as it is prefix. + location /config { + add_header Cache-Control "no-cache"; + } + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; +} + diff --git a/run.sh b/run.sh index ba76a59..b8ca2c9 100755 --- a/run.sh +++ b/run.sh @@ -20,6 +20,10 @@ if $CONTAINER_RUNTIME inspect --type container synapse 1> /dev/null; then $CONTAINER_RUNTIME rm -f synapse sleep 0.5 fi +if $CONTAINER_RUNTIME inspect --type container elementweb 1> /dev/null; then + $CONTAINER_RUNTIME rm -f elementweb + sleep 0.5 +fi if $CONTAINER_RUNTIME inspect --type container nextcloud 1> /dev/null; then $CONTAINER_RUNTIME rm -f nextcloud fi @@ -30,7 +34,9 @@ fi $CONTAINER_RUNTIME run -d \ --name=nextcloud \ - -p 8080:80 \ + -p 8080:8080 \ + -p 8081:80 \ + -p 8082:8082 \ -p 8008:8008 \ -v "$DIR:/var/www/html/custom_apps/upschooling" \ --add-host "synapse:127.0.0.1" \ @@ -128,5 +134,15 @@ else echo -e "Matrix user @upschooling:synapse created. \e[1;38;5;2mOK\033[0m" fi +$CONTAINER_RUNTIME run -d \ + --log-driver "k8s-file" \ + --name=elementweb \ + "--network=container:$($CONTAINER_RUNTIME inspect --format "{{.Id}}" nextcloud)" \ + -v "$DIR/extra/element-web-nginx.conf:/etc/nginx/conf.d/default.conf" \ + --hostname elementweb \ + docker.io/vectorim/element-web + +echo -e "Element Web has started. \e[1;38;5;2mOK\033[0m" + # for nextcloud logs use $CONTAINER_RUNTIME exec --user 33 -it nextcloud ./occ log:watch # for webserver logs use $CONTAINER_RUNTIME logs -f elementweb