Commit fb2122d3 authored by Jürgen Enge's avatar Jürgen Enge
Browse files

Merge branch 'master' of gitlab.switch.ch:memoriav/memobase-2020/services/streaming-server

parents 94448a93 9b8cd100
Pipeline #10408 passed with stages
in 5 minutes and 17 seconds
include: include:
- project: 'memoriav/memobase-2020/utilities/ci-templates' - project: 'memoriav/memobase-2020/utilities/ci-templates'
file: 'docker-image.yml' file: 'docker-image/docker-image.yml'
variables: variables:
DOCKER_TLS_CERTDIR: "" DOCKER_TLS_CERTDIR: ""
......
...@@ -17,6 +17,6 @@ USER appuser ...@@ -17,6 +17,6 @@ USER appuser
ADD web/static/ /app/static ADD web/static/ /app/static
ADD web/template /app/templates ADD web/template /app/templates
EXPOSE 81 EXPOSE 8081
ENTRYPOINT ["/app/app"] ENTRYPOINT ["/app/app"]
...@@ -45,6 +45,7 @@ type Config struct { ...@@ -45,6 +45,7 @@ type Config struct {
CertPEM string CertPEM string
KeyPEM string KeyPEM string
Addr string Addr string
BaseUrl string
StaticDir string StaticDir string
UrlPrefix string UrlPrefix string
CmdPrefix string CmdPrefix string
......
...@@ -94,6 +94,7 @@ func main() { ...@@ -94,6 +94,7 @@ func main() {
fm := memostream.NewFileMapper(mapping) fm := memostream.NewFileMapper(mapping)
srv, err := memostream.NewServer( srv, err := memostream.NewServer(
config.BaseUrl,
config.UrlPrefix, config.UrlPrefix,
config.CmdPrefix, config.CmdPrefix,
config.IIIF.Prefix, config.IIIF.Prefix,
......
logfile = "" # log file location logfile = "" # log file location
loglevel = "DEBUG" # CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG loglevel = "DEBUG" # CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG
accesslog = "" # http access log file accesslog = "" # http access log file
addr = "localhost:82" addr = "localhost:88"
certpem = "" # tls client certificate file in PEM format certpem = "" # tls client certificate file in PEM format
keypem = "" # tls client key file in PEM format keypem = "" # tls client key file in PEM format
staticdir = "C:/daten/go/dev/memobase/streaming-server/web/static/" staticdir = "C:/daten/go/dev/memobase/streaming-server/web/static/"
...@@ -15,14 +15,15 @@ resolverCacheSize = 1000 ...@@ -15,14 +15,15 @@ resolverCacheSize = 1000
errorTemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/error.gohtml" # error message for memoHandler errorTemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/error.gohtml" # error message for memoHandler
videoviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/videojs.gohtml" videoviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/videojs.gohtml"
audioviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/audiohowler.gohtml" audioviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/audiohowler.gohtml"
baseurl = "http://localhost:88"
[[filemap]] [[filemap]]
alias = "c" alias = "c"
folder = "c:/" folder = "C:/"
[[filemap]] [[filemap]]
alias = "blah" alias = "blah"
folder = "c:/temp" folder = "C:/temp"
[iiif] [iiif]
prefix = "/iiif/" prefix = "/iiif/"
......
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: memobase
name: av-volume-claim
labels:
app: mediaserver-app
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: csi-cephfs
volumeMode: Filesystem
apiVersion: apps/v1
kind: Deployment
metadata:
name: mediaserver-deployment
namespace: memobase
labels:
app: mediaserver-app
spec:
selector:
matchLabels:
app: mediaserver-app
replicas: 1
template:
metadata:
labels:
app: mediaserver-app
tier: web
spec:
containers:
- name: mediaserver-container
image: cr.gitlab.switch.ch/memoriav/memobase-2020/services/streaming-server:latest
env:
- name: DSN
valueFrom:
secretKeyRef:
name: mariadb-secret
key: mediaserver
ports:
- containerPort: 8081
name: http
protocol: TCP
imagePullPolicy: Always
volumeMounts:
- name: av-volume
mountPath: /data
- name: config
mountPath: /app/configs
command: ["/app/app", "-cfg", "/app/configs/memostream.toml"]
restartPolicy: Always
volumes:
- name: av-volume
persistentVolumeClaim:
claimName: av-volume-claim
- name: config
configMap:
name: mediaserver-config
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: memobase
name: mediaserver-ingress
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
labels:
app: mediaserver-app
spec:
tls:
- hosts:
- media.memobase.k8s.unibas.ch
secretName: media.memobase.k8s.unibas.ch-tls
rules:
- host: media.memobase.k8s.unibas.ch
http:
paths:
- path: /
backend:
serviceName: mediaserver-service
servicePort: 8081
apiVersion: v1
kind: Service
metadata:
namespace: memobase
name: mediaserver-service
labels:
app: mediaserver-app
spec:
ports:
- port: 8081
selector:
app: mediaserver-app
tier: web
clusterIP: None
...@@ -33,6 +33,7 @@ type Sig struct { ...@@ -33,6 +33,7 @@ type Sig struct {
type memoServer struct { type memoServer struct {
srv *http.Server srv *http.Server
baseUrl string
staticDir string staticDir string
urlPrefix string urlPrefix string
cmdPrefix string cmdPrefix string
...@@ -56,6 +57,7 @@ type memoServer struct { ...@@ -56,6 +57,7 @@ type memoServer struct {
} }
func NewServer( func NewServer(
baseUrl,
urlPrefix, urlPrefix,
cmdPrefix, cmdPrefix,
iiifPrefix, iiifPrefix,
...@@ -101,6 +103,7 @@ func NewServer( ...@@ -101,6 +103,7 @@ func NewServer(
return &memoServer{ return &memoServer{
//mh: NewMemoHandler(baseDir, urlPrefix, resolver, jwtSecret, log, errorTemplate), //mh: NewMemoHandler(baseDir, urlPrefix, resolver, jwtSecret, log, errorTemplate),
baseUrl: baseUrl,
resolver: resolver, resolver: resolver,
mapping: mapping, mapping: mapping,
urlPrefix: urlPrefix, urlPrefix: urlPrefix,
......
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"io" "io"
"log" "log"
"net/http" "net/http"
"net/url"
"path/filepath" "path/filepath"
"strings" "strings"
) )
...@@ -50,11 +51,15 @@ func (ms *memoServer) proxyIIIF(req *http.Request, writer http.ResponseWriter, s ...@@ -50,11 +51,15 @@ func (ms *memoServer) proxyIIIF(req *http.Request, writer http.ResponseWriter, s
} }
} }
// build headers to send cantaloupe the real url's to use // build headers to send cantaloupe the real url's to use
proto, host, port := ms.getProtoHostPort(req) //proto, host, port := ms.getProtoHostPort(req)
req2.Header.Add("X-Forwarded-Proto", proto) baseurl, err := url.Parse(ms.baseUrl)
req2.Header.Add("X-Forwarded-Host", host) if err != nil {
req2.Header.Add("X-Forwarded-Port", port) return emperror.Wrapf(err, "Cannot parse baseurl: %s", ms.baseUrl)
req2.Header.Add("X-Forwarded-Path", SingleJoiningSlash(ms.iiifPrefix, signature+"/"+newtoken)+"/") }
req2.Header.Add("X-Forwarded-Proto", baseurl.Scheme)
req2.Header.Add("X-Forwarded-Host", baseurl.Hostname())
req2.Header.Add("X-Forwarded-Port", baseurl.Port())
req2.Header.Add("X-Forwarded-Path", SingleJoiningSlash(baseurl.RawPath, SingleJoiningSlash(ms.iiifPrefix, signature+"/"+newtoken)+"/"))
req2.Header.Add("X-Forwarded-For", req.RemoteAddr[:strings.IndexByte(req.RemoteAddr, ':')]) req2.Header.Add("X-Forwarded-For", req.RemoteAddr[:strings.IndexByte(req.RemoteAddr, ':')])
rs, err := client.Do(req2) rs, err := client.Do(req2)
......
...@@ -145,13 +145,9 @@ func (ms *memoServer) mainHandler(w http.ResponseWriter, req *http.Request) { ...@@ -145,13 +145,9 @@ func (ms *memoServer) mainHandler(w http.ResponseWriter, req *http.Request) {
} }
} }
scheme := "http" tileSource := fmt.Sprintf("%s/%s/%s/iiif/info.json?auth=%s",
if req.TLS != nil { strings.TrimRight(ms.baseUrl, "/"),
scheme = "https" ms.urlPrefix,
}
tileSource := fmt.Sprintf("%s://%s/%s/%s/iiif/info.json?auth=%s", scheme,
req.Host,
strings.Trim(ms.urlPrefix, "/"),
signature, signature,
newtoken) newtoken)
if me.Protocol == Media_Redirect { if me.Protocol == Media_Redirect {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment