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:
- project: 'memoriav/memobase-2020/utilities/ci-templates'
file: 'docker-image.yml'
file: 'docker-image/docker-image.yml'
variables:
DOCKER_TLS_CERTDIR: ""
......
......@@ -17,6 +17,6 @@ USER appuser
ADD web/static/ /app/static
ADD web/template /app/templates
EXPOSE 81
EXPOSE 8081
ENTRYPOINT ["/app/app"]
......@@ -45,6 +45,7 @@ type Config struct {
CertPEM string
KeyPEM string
Addr string
BaseUrl string
StaticDir string
UrlPrefix string
CmdPrefix string
......
......@@ -94,6 +94,7 @@ func main() {
fm := memostream.NewFileMapper(mapping)
srv, err := memostream.NewServer(
config.BaseUrl,
config.UrlPrefix,
config.CmdPrefix,
config.IIIF.Prefix,
......
logfile = "" # log file location
loglevel = "DEBUG" # CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG
accesslog = "" # http access log file
addr = "localhost:82"
addr = "localhost:88"
certpem = "" # tls client certificate file in PEM format
keypem = "" # tls client key file in PEM format
staticdir = "C:/daten/go/dev/memobase/streaming-server/web/static/"
......@@ -15,14 +15,15 @@ resolverCacheSize = 1000
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"
audioviewertemplate = "C:/daten/go/dev/memobase/streaming-server/web/template/audiohowler.gohtml"
baseurl = "http://localhost:88"
[[filemap]]
alias = "c"
folder = "c:/"
folder = "C:/"
[[filemap]]
alias = "blah"
folder = "c:/temp"
folder = "C:/temp"
[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 {
type memoServer struct {
srv *http.Server
baseUrl string
staticDir string
urlPrefix string
cmdPrefix string
......@@ -56,6 +57,7 @@ type memoServer struct {
}
func NewServer(
baseUrl,
urlPrefix,
cmdPrefix,
iiifPrefix,
......@@ -101,6 +103,7 @@ func NewServer(
return &memoServer{
//mh: NewMemoHandler(baseDir, urlPrefix, resolver, jwtSecret, log, errorTemplate),
baseUrl: baseUrl,
resolver: resolver,
mapping: mapping,
urlPrefix: urlPrefix,
......
......@@ -16,6 +16,7 @@ import (
"io"
"log"
"net/http"
"net/url"
"path/filepath"
"strings"
)
......@@ -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
proto, host, port := ms.getProtoHostPort(req)
req2.Header.Add("X-Forwarded-Proto", proto)
req2.Header.Add("X-Forwarded-Host", host)
req2.Header.Add("X-Forwarded-Port", port)
req2.Header.Add("X-Forwarded-Path", SingleJoiningSlash(ms.iiifPrefix, signature+"/"+newtoken)+"/")
//proto, host, port := ms.getProtoHostPort(req)
baseurl, err := url.Parse(ms.baseUrl)
if err != nil {
return emperror.Wrapf(err, "Cannot parse baseurl: %s", ms.baseUrl)
}
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, ':')])
rs, err := client.Do(req2)
......
......@@ -145,13 +145,9 @@ func (ms *memoServer) mainHandler(w http.ResponseWriter, req *http.Request) {
}
}
scheme := "http"
if req.TLS != nil {
scheme = "https"
}
tileSource := fmt.Sprintf("%s://%s/%s/%s/iiif/info.json?auth=%s", scheme,
req.Host,
strings.Trim(ms.urlPrefix, "/"),
tileSource := fmt.Sprintf("%s/%s/%s/iiif/info.json?auth=%s",
strings.TrimRight(ms.baseUrl, "/"),
ms.urlPrefix,
signature,
newtoken)
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