Skip to content

Latest commit

 

History

History
122 lines (91 loc) · 5.1 KB

CONFIGURATION.md

File metadata and controls

122 lines (91 loc) · 5.1 KB

TOML Configuration for Imageflow.Server.Host

Hooray! You no longer need a build step to deploy Imageflow Server. We're publishing a precompiled project that uses Imageflow.Server.Configuration.

That said, having a repository with your configuration and some automated deploy/CI is still a GREAT idea, so you may copy/paste Imageflow.Server.Host into your own project, or use it as a reference for your own deployment.

NOTE: This is a work-in-progress, bugs may exist, and error messages when you mess the config file up may be confusing. Please report any issues.

If you get HTTP Error 500.30 - ASP.NET Core app failed to start, open Event Viewer and check the Application log - you probably have an invalid .toml configuration, or one of the directories you referenced from imageflow.toml doesn't exist. Make sure they all exist!

Known issues

  • Doesn't auto-restart when you edit imageflow.toml
  • env.HOME doesn't work on windows. Use env.TEMP instead for a good default image cache folder
  • app.wwwroot shouldn't be used, wwwroot isn't reliably defined and is just a bad idea with ASP.NET 7. Use '${app.approot}/public' instead.
  • No support for configuring S3 or Azure or remote HTTP sources yet. It's tricky to get just right and in an extensible way; I've supported <resizer> in Web.config for 15 years, so I want to avoid breakage.

General ASP.NET deployment help.

Imageflow.Server.Host can be copy/pasted into your IIS site, and configured with imageflow.toml Don't forget to install the ASP.NET Hosting Bundle if you're deploying to windows.

Deploying an ASP.NET app

imageflow.toml reference

[imageflow_server] # must be valid TOML https://toml.io/en/ 
config_schema = '1.0' # Breaking changes in new versions may require this to be incremented

[license]
enforcement = "watermark" # or http_402_error/http_422_error, for fast failures
key = """
[PUT YOUR LICENSE KEY HERE]
""" # triple-quoted strings can span multiple lines


## Define routes, and map them to physical folders on disk
[route_defaults]
prefix_case_sensitive = true
lowercase_path_remainder = false
cache_control = "public, max-age=2592000"
# The following commands will be applied to all images, unless overridden
apply_default_commands = "quality=76&webp.quality=70&f.sharpen=23&down.filter=mitchell"

[[routes]]
prefix = '/images/'
map_to_physical_folder='${app.approot}\images\'

# ======  Caching to disk ======
[disk_cache] # HybridCache
enabled = true #required
# Don't put this on high-latency network storage, it will be slow
# Also cannot be inside an IIS website (unlike ImageResizer)
folder = '${env.TEMP}\ImageflowCache' # required
cache_size_mb = 30_000           # Disk space usage limit in MB
#write_queue_ram_mb = 200          # How much RAM to permit for async writes

# The number of shards to split the metabase into (default: 8)
# More shards = more open write-ahead-log files, slower shutdown,
# but less lock contention and faster cache hits
# database_shards = 8 # Manually delete the cache dir if you change this
# seconds_until_evictable = 30 # How long before a newly-written file can be deleted


# ======  Diagnostics access ======
# Prefix keys with 'production.', 'staging.', or 'development.' 
# to merge with the appropriate section based on the current environment
# Defaults to 'production' if DOTNET_ENVIRONMENT and ASPNETCORE_ENVIRONMENT are not set
[diagnostics]
# Access anywhere with /imageflow.debug?password=[[redacted]]
#allow_with_password = "[[redacted_must_be_12+chars]]"
# Allow localhost without a password
allow_localhost = true

# In development mode, allow any host without a password
[development.diagnostics]
allow_anyhost = true

# ======  ASP.NET Server settings ======
[aspnet_server]
use_developer_exception_page = false # Don't leak error details to the public
use_exception_handler = "/error"     # Use a custom error page (defined below)
use_hsts = true                      # Allow no HTTP connections whatsoever
use_https_redirection = true         # Redirect all HTTP requests to HTTPS, if any get through

# ASP.NET supports a subset of the apache mod_rewrite syntax
# [aspnet_server.apache_mod_rewrite]
# file = "${app.approot}\\apache_rewrites.ini"

[development.aspnet_server]
use_developer_exception_page = true # Error details in dev please
use_hsts = false                    # Don't ban unencrypted HTTP in development
use_https_redirection = false       # Or redirect to HTTPS

[[static_response]]
for = "/error" # required
status_code = 500 # required
cache_control = "no-cache"
content_type = "text/html" # required
content = '<p>An error has occurred while processing the request.</p>' # required
# file = "/var/www/error.html"

[security.max_decode_resolution]
width = 12000
height = 12000
megapixels = 80

[security.max_encode_resolution]
width = 12000
height = 12000
megapixels = 40

[security.max_frame_resolution]
width = 12000
height = 12000
megapixels = 80