File size: 1,454 Bytes
31a23c4
39f4326
bb2cb85
31a23c4
 
0aaf2da
6740ce5
1fcadb1
933cae1
54b5731
 
 
 
9d5ca0f
39d177e
 
 
 
e289cb1
9d5ca0f
 
 
 
 
 
 
 
54b5731
f5444c8
54b5731
f5444c8
dbc02dd
42443ec
f5444c8
42443ec
54b5731
 
 
f5444c8
 
 
 
 
 
 
 
 
 
54b5731
 
2cb270c
870fde8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
FROM  ghcr.io/aurora-develop/aurora:latest AS builder
FROM debian
WORKDIR /app
COPY --from=builder /app/aurora /app/aurora
COPY --from=builder /app/harPool /app/harPool
RUN apt-get update -y && apt-get install -y nodejs npm
RUN npm install express http-proxy-middleware
COPY anakin_proxy_linux_amd64 /app/anakin
COPY <<EOF /app/index.js
const express = require("express");
const app = express();
const { createProxyMiddleware } = require("http-proxy-middleware");

function authMiddleware(req, res, next) {
  res.setHeader('Access-Control-Allow-Origin','*');
  res.setHeader('Access-Control-Allow-Headers','*');
  if(req.method === "OPTIONS") return res.status(204).end();
  
  if (!process.env.authorization || (req.headers.authorization||req.url).indexOf(process.env.authorization)>-1) {
    next();
  } else {
    res.status(401).json({ error: 'Unauthorized' });
  }
}

app.use(authMiddleware);

app.use(
    "/aurora",
    createProxyMiddleware({
        target: "http://127.0.0.1:8080/",
        changeOrigin: true,
        pathRewrite: {
          '^/aurora': '',
        },
    })
);

app.use(
    "/anakin",
    createProxyMiddleware({
        target: "http://127.0.0.1:8000/",
        changeOrigin: true,
        pathRewrite: {
          '^/anakin': '',
        },
    })
);
app.listen(7860, () => console.log(`Example app listening on port ${port}!`));
EOF
RUN chmod -R u+rwx,g+rwx,o+rwx /app

CMD /app/aurora & /app/anakin & node /app/index.js