-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
897ce93
commit 68fecde
Showing
8 changed files
with
185 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<img src="https://docs.momentohq.com/img/logo.svg" alt="logo" width="400"/> | ||
|
||
# Using Momento With A Proxy | ||
|
||
Momento `SimpleCacheClient` connections can be proxied with relative ease. We'll provide an example here, using | ||
[HA Proxy](https://www.haproxy.com/) as a layer 4 proxy on localhost. | ||
|
||
## Configuring HA Proxy | ||
|
||
To configure HA Proxy you'll need two available local ports, one for the control plane and the other for the cache | ||
plane. You'll also need the hostnames of the actual control plane and cache plane servers that your account is | ||
configured to connect to. If you're using a JWT to authenticate with Momento, you can extract the hostnames for the | ||
control plane (cp) and cache plane (c) with the following shell command: | ||
|
||
```shell | ||
echo $MOMENTO_AUTH_TOKEN | awk -F . {'print $2}' | base64 -d | ||
``` | ||
|
||
A sample configuration (using nonexistent server hostnames) is as follows: | ||
|
||
```text | ||
frontend control-plane-fe | ||
bind localhost:4443 | ||
option tcplog | ||
mode tcp | ||
default_backend control-plane-be | ||
backend control-plane-be | ||
mode tcp | ||
server server1 control.some-control-cell-name.momentohq.com:443 | ||
frontend cache-plane-fe | ||
bind localhost:4444 | ||
option tcplog | ||
mode tcp | ||
default_backend cache-plane-fe | ||
backend cache-plane-fe | ||
mode tcp | ||
server server1 cache.some-cache-cell-name.momentohq.com:443 | ||
``` | ||
|
||
## Configuring the Momento Client | ||
|
||
Configuring the Momento client to use the proxy requires the same information, which is passed to the credential | ||
provider. Using the `EnvMomentoTokenProvider`, which reads the token from an environment variable: | ||
|
||
```php | ||
$authProvider = new EnvMomentoTokenProvider( | ||
// name of the environment variable that contains our auth token | ||
"MOMENTO_AUTH_TOKEN", | ||
// host and port to connect to haproxy for the control plane | ||
"localhost:4443", | ||
// host and port to connect to haproxy for the cache plane | ||
"localhost:4444", | ||
// host and port to connect haproxy to Momento's control plane | ||
"control.some-control-cell-name.momentohq.com:443", | ||
// host and port to connect haproxy to Momento's cache plane | ||
"cache.some-cache-cell-name.momentohq.com:443" | ||
); | ||
``` | ||
|
||
This configuration instructs the client to connect through the proxy server, **overriding the target name used for SSL | ||
host name checking**. | ||
|
||
---------------------------------------------------------------------------------------- | ||
For more info, visit our website at [https://gomomento.com](https://gomomento.com)! |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.