production.rb 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. def env_trusted_proxies
  3. return nil if ENV['RAILS_TRUSTED_PROXIES'].blank?
  4. if ENV['RAILS_TRUSTED_PROXIES'].strip.start_with?('[')
  5. # Backwards compatibility for Docker environments setting the variable to a
  6. # Ruby literal like "['127.0.0.1', '::1']".
  7. eval(ENV['RAILS_TRUSTED_PROXIES']) # rubocop:disable Security/Eval
  8. else
  9. # The regular way: variable contains a list if IP addresses/masks: "127.0.0.1,::1"
  10. ENV['RAILS_TRUSTED_PROXIES'].split(',').compact_blank
  11. end
  12. end
  13. Rails.application.configure do
  14. # Settings specified here will take precedence over those in config/application.rb.
  15. # Code is not reloaded between requests.
  16. config.cache_classes = true
  17. # Eager load code on boot. This eager loads most of Rails and
  18. # your application in memory, allowing both threaded web servers
  19. # and those relying on copy on write to perform better.
  20. # Rake tasks automatically ignore this option for performance.
  21. config.eager_load = true
  22. # Full error reports are disabled and caching is turned on.
  23. config.consider_all_requests_local = false
  24. config.action_controller.perform_caching = true
  25. # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
  26. # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
  27. # config.require_master_key = true
  28. # Disable serving static files from the `/public` folder by default since
  29. # Apache or NGINX already handles this.
  30. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
  31. # Compress JavaScripts and CSS.
  32. config.assets.js_compressor = :terser
  33. # config.assets.css_compressor = :sass
  34. # Do not fallback to assets pipeline if a precompiled asset is missed.
  35. config.assets.compile = false
  36. # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
  37. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  38. # config.action_controller.asset_host = 'http://assets.example.com'
  39. # Specifies the header that your server uses for sending files.
  40. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
  41. # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
  42. # Store uploaded files on the local file system (see config/storage.yml for options).
  43. # config.active_storage.service = :local
  44. # Mount Action Cable outside main process or domain.
  45. # config.action_cable.mount_path = nil
  46. # config.action_cable.url = 'wss://example.com/cable'
  47. # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
  48. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  49. # config.force_ssl = true
  50. # Use the lowest log level to ensure availability of diagnostic information
  51. # when problems arise.
  52. config.log_level = :info
  53. # Prepend all log lines with the following tags.
  54. config.log_tags = [ :request_id ]
  55. # Use a different cache store in production.
  56. # config.cache_store = :mem_cache_store
  57. # Use a real queuing backend for Active Job (and separate queues per environment).
  58. # config.active_job.queue_adapter = :resque
  59. # config.active_job.queue_name_prefix = "zammad_#{Rails.env}"
  60. config.action_mailer.perform_caching = false
  61. # Ignore bad email addresses and do not raise email delivery errors.
  62. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  63. # config.action_mailer.raise_delivery_errors = false
  64. # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  65. # the I18n.default_locale when a translation cannot be found).
  66. config.i18n.fallbacks = true
  67. # Enable autoload
  68. config.dependency_loading = true
  69. # Send deprecation notices to registered listeners.
  70. config.active_support.deprecation = :notify
  71. # Use default logging formatter so that PID and timestamp are not suppressed.
  72. # config.log_formatter = ::Logger::Formatter.new
  73. # Use a different logger for distributed setups.
  74. # require 'syslog/logger'
  75. # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
  76. if ENV['RAILS_LOG_TO_STDOUT'].present?
  77. logger = ActiveSupport::Logger.new($stdout)
  78. logger.formatter = config.log_formatter
  79. config.logger = ActiveSupport::TaggedLogging.new(logger)
  80. end
  81. # Do not dump schema after migrations.
  82. config.active_record.dump_schema_after_migration = false
  83. # Overwrite default Rails TRUSTED_PROXIES because otherwise IPs from private ranges will be
  84. # ignored for Session logging and fall back to localhost (https://github.com/zammad/zammad/issues/742).
  85. config.action_dispatch.trusted_proxies = env_trusted_proxies || ['127.0.0.1', '::1']
  86. end