diff --git a/docs/basic-usage/ssl.md b/docs/basic-usage/ssl.md index b538290..5320840 100644 --- a/docs/basic-usage/ssl.md +++ b/docs/basic-usage/ssl.md @@ -270,28 +270,20 @@ You know you've reached this limit of your Nginx error logs contain similar mess Remember to restart your Nginx after you've modified the `worker_connections`. -### Example using Caddy +### Example using Caddy v2 -[Caddy](https://caddyserver.com) can also be used to automatically obtain a TLS certificate from Let's Encrypt and terminate TLS before proxying to your echo server. +[Caddy](https://caddyserver.com) can also be used to automatically obtain a TLS certificate from Let's Encrypt and terminate TLS before proxying to your websocket server. An example configuration would look like this: ``` socket.yourapp.tld { - rewrite / { - if {>Connection} has Upgrade - if {>Upgrade} is websocket - to /websocket-proxy/{path}?{query} + @ws { + header Connection *Upgrade* + header Upgrade websocket } - - proxy /websocket-proxy 127.0.0.1:6001 { - without /special-websocket-url - transparent - websocket - } - - tls youremail.com + reverse_proxy @ws 127.0.0.1:6001 } ``` -Note the `to /websocket-proxy`, this is a dummy path to allow the `proxy` directive to only proxy on websocket connections. This should be a path that will never be used by your application's routing. Also, note that you should change `127.0.0.1` to the hostname of your websocket server. For example, if you're running in a Docker environment, this might be the container name of your websocket server. +Note that you should change `127.0.0.1` to the hostname of your websocket server. For example, if you're running in a Docker environment, this might be the container name of your websocket server. diff --git a/src/Apps/App.php b/src/Apps/App.php index ae23f4d..acb2150 100644 --- a/src/Apps/App.php +++ b/src/Apps/App.php @@ -6,7 +6,7 @@ use BeyondCode\LaravelWebSockets\Exceptions\InvalidApp; class App { - /** @var int */ + /** @var string|int */ public $id; /** @var string */ @@ -39,7 +39,7 @@ class App /** * Find the app by id. * - * @param mixed $appId + * @param string|int $appId * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public static function findById($appId) @@ -50,7 +50,7 @@ class App /** * Find the app by app key. * - * @param mixed $appId + * @param string $appKey * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public static function findByKey($appKey): ?self @@ -61,7 +61,7 @@ class App /** * Find the app by app secret. * - * @param mixed $appId + * @param string $appSecret * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public static function findBySecret($appSecret): ?self @@ -72,9 +72,9 @@ class App /** * Initialize the Web Socket app instance. * - * @param mixed $appId - * @param mixed $key - * @param mixed $secret + * @param string|int $appId + * @param string $key + * @param string $secret * @return void * @throws \BeyondCode\LaravelWebSockets\Exceptions\InvalidApp */ diff --git a/src/Apps/AppManager.php b/src/Apps/AppManager.php index 03c0c9e..86497c0 100644 --- a/src/Apps/AppManager.php +++ b/src/Apps/AppManager.php @@ -14,7 +14,7 @@ interface AppManager /** * Get app by id. * - * @param mixed $appId + * @param string|int $appId * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public function findById($appId): ?App; @@ -22,7 +22,7 @@ interface AppManager /** * Get app by app key. * - * @param mixed $appKey + * @param string $appKey * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public function findByKey($appKey): ?App; @@ -30,7 +30,7 @@ interface AppManager /** * Get app by secret. * - * @param mixed $appSecret + * @param string $appSecret * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public function findBySecret($appSecret): ?App; diff --git a/src/Apps/ConfigAppManager.php b/src/Apps/ConfigAppManager.php index 3136ad6..03e5458 100644 --- a/src/Apps/ConfigAppManager.php +++ b/src/Apps/ConfigAppManager.php @@ -38,7 +38,7 @@ class ConfigAppManager implements AppManager /** * Get app by id. * - * @param mixed $appId + * @param string|int $appId * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public function findById($appId): ?App @@ -53,7 +53,7 @@ class ConfigAppManager implements AppManager /** * Get app by app key. * - * @param mixed $appKey + * @param string $appKey * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public function findByKey($appKey): ?App @@ -68,7 +68,7 @@ class ConfigAppManager implements AppManager /** * Get app by secret. * - * @param mixed $appSecret + * @param string $appSecret * @return \BeyondCode\LaravelWebSockets\Apps\App|null */ public function findBySecret($appSecret): ?App