mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 23:48:27 +00:00
Pass requests made by remote servers for media to the media API (#263)
This commit is contained in:
parent
3dd30858d1
commit
9ed609b9df
2 changed files with 56 additions and 41 deletions
75
INSTALL.md
75
INSTALL.md
|
@ -109,46 +109,46 @@ The following contains scripts which will run all the required processes in orde
|
|||
```
|
||||
|
||||
/media +---------------------------+
|
||||
+--------->| dendrite-media-api-server |
|
||||
| +---------------------------+
|
||||
| :7774
|
||||
|
|
||||
|
|
||||
|/directory+----------------------------------+
|
||||
+--------->| dendrite-public-rooms-api-server |<========++
|
||||
| +----------------------------------+ ||
|
||||
| :7775 | ||
|
||||
+----------->+------------->| dendrite-media-api-server |
|
||||
^ ^ +---------------------------+
|
||||
| | :7774
|
||||
| |
|
||||
| |
|
||||
| | /directory +----------------------------------+
|
||||
| | +--------->| dendrite-public-rooms-api-server |<========++
|
||||
| | | +----------------------------------+ ||
|
||||
| | | :7775 | ||
|
||||
| | | +<-----------+ ||
|
||||
| | | | ||
|
||||
| | | /sync +--------------------------+ ||
|
||||
| | +--------->| dendrite-sync-api-server |<================++
|
||||
| | | | +--------------------------+ ||
|
||||
| | | | :7773 | ^^ ||
|
||||
Matrix +------------------+ | | | | || client_data ||
|
||||
Clients --->| client-api-proxy |-------+ +<-----------+ ++=============++ ||
|
||||
+------------------+ | | | || ||
|
||||
:8008 | | CS API +----------------------------+ || ||
|
||||
| +--------->| dendrite-client-api-server |==++ ||
|
||||
| | +----------------------------+ ||
|
||||
| | :7771 | ||
|
||||
| | | ||
|
||||
| +<-----------+ ||
|
||||
| | ||
|
||||
| /sync +--------------------------+ ||
|
||||
+--------->| dendrite-sync-api-server |<================++
|
||||
| | +--------------------------+ ||
|
||||
| | :7773 | ^^ ||
|
||||
Matrix +------------------+ | | | || client_data ||
|
||||
Clients --->| client-api-proxy |---+ +<-----------+ ++=============++ ||
|
||||
+------------------+ | | || ||
|
||||
:8008 | CS API +----------------------------+ || ||
|
||||
+--------->| dendrite-client-api-server |==++ ||
|
||||
| +----------------------------+ ||
|
||||
| :7771 | ||
|
||||
| | ||
|
||||
+<-----------+ ||
|
||||
| ||
|
||||
| ||
|
||||
| +----------------------+ room_event ||
|
||||
+---------->| dendrite-room-server |===============++
|
||||
| +----------------------+ ||
|
||||
| :7770 ||
|
||||
| ++==========================++
|
||||
+<------------+ ||
|
||||
| | VV
|
||||
| +-----------------------------------+ Matrix
|
||||
| | dendrite-federation-sender-server |------------> Servers
|
||||
| +-----------------------------------+
|
||||
| :7776
|
||||
|
|
||||
+<-----------+
|
||||
|
|
||||
| | +----------------------+ room_event ||
|
||||
| +---------->| dendrite-room-server |===============++
|
||||
| | +----------------------+ ||
|
||||
| | :7770 ||
|
||||
| | ++==========================++
|
||||
| +<------------+ ||
|
||||
| | | VV
|
||||
| | +-----------------------------------+ Matrix
|
||||
| | | dendrite-federation-sender-server |------------> Servers
|
||||
| | +-----------------------------------+
|
||||
| | :7776
|
||||
| |
|
||||
+---------->+ +<-----------+
|
||||
| |
|
||||
Matrix +----------------------+ SS API +--------------------------------+
|
||||
Servers --->| federation-api-proxy |--------->| dendrite-federation-api-server |
|
||||
+----------------------+ +--------------------------------+
|
||||
|
@ -222,6 +222,7 @@ This is what Matrix servers will talk to. This is only required if you want to s
|
|||
./bin/federation-api-proxy \
|
||||
--bind-address ":8448" \
|
||||
--federation-api-url "http://localhost:7772" \
|
||||
--media-api-server-url "http://localhost:7774" \
|
||||
```
|
||||
|
||||
### Run a federation api server
|
||||
|
|
|
@ -48,6 +48,7 @@ Arguments:
|
|||
|
||||
var (
|
||||
federationAPIURL = flag.String("federation-api-url", "", "The base URL of the listening 'dendrite-federation-api-server' process. E.g. 'http://localhost:4200'")
|
||||
mediaAPIURL = flag.String("media-api-server-url", "", "The base URL of the listening 'dendrite-media-api-server' process. E.g. 'http://localhost:7779'")
|
||||
bindAddress = flag.String("bind-address", ":8448", "The listening port for the proxy.")
|
||||
certFile = flag.String("tls-cert", "server.crt", "The PEM formatted X509 certificate to use for TLS")
|
||||
keyFile = flag.String("tls-key", "server.key", "The PEM private key to use for TLS")
|
||||
|
@ -104,11 +105,23 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
if *mediaAPIURL == "" {
|
||||
flag.Usage()
|
||||
fmt.Fprintln(os.Stderr, "no --media-api-server-url specified.")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
federationProxy, err := makeProxy(*federationAPIURL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mediaProxy, err := makeProxy(*mediaAPIURL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
http.Handle("/_matrix/media/v1/", mediaProxy)
|
||||
http.Handle("/", federationProxy)
|
||||
|
||||
srv := &http.Server{
|
||||
|
@ -118,6 +131,7 @@ func main() {
|
|||
}
|
||||
|
||||
fmt.Println("Proxying requests to:")
|
||||
fmt.Println(" /_matrix/media/v1 => ", *mediaAPIURL+"/api/_matrix/media/v1")
|
||||
fmt.Println(" /* => ", *federationAPIURL+"/api/*")
|
||||
fmt.Println("Listening on ", *bindAddress)
|
||||
panic(srv.ListenAndServeTLS(*certFile, *keyFile))
|
||||
|
|
Loading…
Reference in a new issue