mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-15 22:31:07 +01: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
83
INSTALL.md
83
INSTALL.md
|
@ -108,47 +108,47 @@ The following contains scripts which will run all the required processes in orde
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
/media +---------------------------+
|
/media +---------------------------+
|
||||||
+--------->| dendrite-media-api-server |
|
+----------->+------------->| dendrite-media-api-server |
|
||||||
| +---------------------------+
|
^ ^ +---------------------------+
|
||||||
| :7774
|
| | :7774
|
||||||
|
|
| |
|
||||||
|
|
| |
|
||||||
|/directory+----------------------------------+
|
| | /directory +----------------------------------+
|
||||||
+--------->| dendrite-public-rooms-api-server |<========++
|
| | +--------->| dendrite-public-rooms-api-server |<========++
|
||||||
| +----------------------------------+ ||
|
| | | +----------------------------------+ ||
|
||||||
| :7775 | ||
|
| | | :7775 | ||
|
||||||
| +<-----------+ ||
|
| | | +<-----------+ ||
|
||||||
| | ||
|
| | | | ||
|
||||||
| /sync +--------------------------+ ||
|
| | | /sync +--------------------------+ ||
|
||||||
+--------->| dendrite-sync-api-server |<================++
|
| | +--------->| dendrite-sync-api-server |<================++
|
||||||
| | +--------------------------+ ||
|
| | | | +--------------------------+ ||
|
||||||
| | :7773 | ^^ ||
|
| | | | :7773 | ^^ ||
|
||||||
Matrix +------------------+ | | | || client_data ||
|
Matrix +------------------+ | | | | || client_data ||
|
||||||
Clients --->| client-api-proxy |---+ +<-----------+ ++=============++ ||
|
Clients --->| client-api-proxy |-------+ +<-----------+ ++=============++ ||
|
||||||
+------------------+ | | || ||
|
+------------------+ | | | || ||
|
||||||
:8008 | CS API +----------------------------+ || ||
|
:8008 | | CS API +----------------------------+ || ||
|
||||||
+--------->| dendrite-client-api-server |==++ ||
|
| +--------->| dendrite-client-api-server |==++ ||
|
||||||
| +----------------------------+ ||
|
| | +----------------------------+ ||
|
||||||
| :7771 | ||
|
| | :7771 | ||
|
||||||
| | ||
|
| | | ||
|
||||||
+<-----------+ ||
|
| +<-----------+ ||
|
||||||
| ||
|
| | ||
|
||||||
| ||
|
| | ||
|
||||||
| +----------------------+ room_event ||
|
| | +----------------------+ room_event ||
|
||||||
+---------->| dendrite-room-server |===============++
|
| +---------->| dendrite-room-server |===============++
|
||||||
| +----------------------+ ||
|
| | +----------------------+ ||
|
||||||
| :7770 ||
|
| | :7770 ||
|
||||||
| ++==========================++
|
| | ++==========================++
|
||||||
+<------------+ ||
|
| +<------------+ ||
|
||||||
| | VV
|
| | | VV
|
||||||
| +-----------------------------------+ Matrix
|
| | +-----------------------------------+ Matrix
|
||||||
| | dendrite-federation-sender-server |------------> Servers
|
| | | dendrite-federation-sender-server |------------> Servers
|
||||||
| +-----------------------------------+
|
| | +-----------------------------------+
|
||||||
| :7776
|
| | :7776
|
||||||
|
|
| |
|
||||||
+<-----------+
|
+---------->+ +<-----------+
|
||||||
|
|
| |
|
||||||
Matrix +----------------------+ SS API +--------------------------------+
|
Matrix +----------------------+ SS API +--------------------------------+
|
||||||
Servers --->| federation-api-proxy |--------->| dendrite-federation-api-server |
|
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 \
|
./bin/federation-api-proxy \
|
||||||
--bind-address ":8448" \
|
--bind-address ":8448" \
|
||||||
--federation-api-url "http://localhost:7772" \
|
--federation-api-url "http://localhost:7772" \
|
||||||
|
--media-api-server-url "http://localhost:7774" \
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run a federation api server
|
### Run a federation api server
|
||||||
|
|
|
@ -48,6 +48,7 @@ Arguments:
|
||||||
|
|
||||||
var (
|
var (
|
||||||
federationAPIURL = flag.String("federation-api-url", "", "The base URL of the listening 'dendrite-federation-api-server' process. E.g. 'http://localhost:4200'")
|
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.")
|
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")
|
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")
|
keyFile = flag.String("tls-key", "server.key", "The PEM private key to use for TLS")
|
||||||
|
@ -104,11 +105,23 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *mediaAPIURL == "" {
|
||||||
|
flag.Usage()
|
||||||
|
fmt.Fprintln(os.Stderr, "no --media-api-server-url specified.")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
federationProxy, err := makeProxy(*federationAPIURL)
|
federationProxy, err := makeProxy(*federationAPIURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mediaProxy, err := makeProxy(*mediaAPIURL)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Handle("/_matrix/media/v1/", mediaProxy)
|
||||||
http.Handle("/", federationProxy)
|
http.Handle("/", federationProxy)
|
||||||
|
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
|
@ -118,6 +131,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Proxying requests to:")
|
fmt.Println("Proxying requests to:")
|
||||||
|
fmt.Println(" /_matrix/media/v1 => ", *mediaAPIURL+"/api/_matrix/media/v1")
|
||||||
fmt.Println(" /* => ", *federationAPIURL+"/api/*")
|
fmt.Println(" /* => ", *federationAPIURL+"/api/*")
|
||||||
fmt.Println("Listening on ", *bindAddress)
|
fmt.Println("Listening on ", *bindAddress)
|
||||||
panic(srv.ListenAndServeTLS(*certFile, *keyFile))
|
panic(srv.ListenAndServeTLS(*certFile, *keyFile))
|
||||||
|
|
Loading…
Reference in a new issue