diff --git a/INSTALL.md b/INSTALL.md index 693d0e999..2c648071c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -250,3 +250,22 @@ To be able to create your first news, you will need to add sections with link Be sure to set title `LinuxFr.org` to one of your sections, otherwise you won't be able to create news in the redaction space. + +## Alternative Redis configuration + +Default Redis configuration is `redis://localhost:6379/0` and for the 1h cache +`redis://localhost:6379/1/cache`. + +You can override the configuration with the following environment variables: + +- `REDIS_HOST` for the hostname or the IP of your Redis server +- `REDIS_PORT` for the port (default TCP 6379) +- `REDIS_URL` for the full address (like `redis://127.0.0.1:6379/0`) +- `REDIS_CACHE_URL` for the cache full address (like `redis://127.0.0.1:6379/1/cache`) + +The first three environment variables are classic for Redis. +The last one about the cache is specific to LinuxFr.org CMS configuration. + +Warning: the current configuration doesn't support authentication or TLS. Be +careful with a remote Redis because everything will be exchange in plain text, +and you exposed your Redis server on the network. diff --git a/config/environments/alpha.rb b/config/environments/alpha.rb index 8289b34ea..188373e82 100644 --- a/config/environments/alpha.rb +++ b/config/environments/alpha.rb @@ -53,7 +53,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - config.cache_store = :redis_cache_store, { url: "redis://localhost:6379/1/cache", expires_in: 1.hour } + config.cache_store = :redis_cache_store, { url: ENV.has_value?("REDIS_CACHE_URL") ? ENV["REDIS_CACHE_URL"] : "redis://localhost:6379/1/cache", expires_in: 1.hour } config.action_mailer.perform_caching = false diff --git a/config/environments/production.rb b/config/environments/production.rb index fd686c098..06b13fa25 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -53,7 +53,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - config.cache_store = :redis_cache_store, { url: "redis://localhost:6379/1/cache", expires_in: 1.hour } + config.cache_store = :redis_cache_store, { url: ENV.has_value?("REDIS_CACHE_URL") ? ENV["REDIS_CACHE_URL"] : "redis://localhost:6379/1/cache", expires_in: 1.hour } config.action_mailer.perform_caching = false