diff --git a/etc/matrix-synapse/homeserver.yaml b/etc/matrix-synapse/homeserver.yaml index f088eb5..9d0e78a 100644 --- a/etc/matrix-synapse/homeserver.yaml +++ b/etc/matrix-synapse/homeserver.yaml @@ -806,7 +806,7 @@ caches: # accessed before being evicted. Defaults to None, which means # entries are never evicted based on time. # - expiry_time: 24h + #expiry_time: 24h # Controls how long the results of a /sync request are cached for after # a successful response is returned. A higher duration can help clients with diff --git a/etc/matrix-synapse/log.yaml b/etc/matrix-synapse/log.yaml index f046a15..ad75541 100644 --- a/etc/matrix-synapse/log.yaml +++ b/etc/matrix-synapse/log.yaml @@ -7,7 +7,7 @@ # be ingested by ELK stacks. See [2] for details. # # [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema -# [2]: https://github.com/matrix-org/synapse/blob/master/docs/structured_logging.md +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html version: 1 @@ -24,18 +24,31 @@ handlers: backupCount: 3 # Does not include the current log file. encoding: utf8 - # Default to buffering writes to log file for efficiency. This means that - # will be a delay for INFO/DEBUG logs to get written, but WARNING/ERROR - # logs will still be flushed immediately. + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. buffer: - class: logging.handlers.MemoryHandler + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler target: file - # The capacity is the number of log lines that are buffered before - # being written to disk. Increasing this will lead to better + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better # performance, at the expensive of it taking longer for log lines to # be written to disk. + # This parameter is required. capacity: 10 - flushLevel: 30 # Flush for WARNING logs as well + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 # A handler that writes logs to stderr. Unused by default, but can be used # instead of "buffer" and "file" in the logger handlers. diff --git a/etc/matrix-synapse/workers/appservice_log_config.yaml b/etc/matrix-synapse/workers/appservice_log_config.yaml index b572305..0972f75 100644 --- a/etc/matrix-synapse/workers/appservice_log_config.yaml +++ b/etc/matrix-synapse/workers/appservice_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_appservice.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/federation_sender1_log_config.yaml b/etc/matrix-synapse/workers/federation_sender1_log_config.yaml index 0483936..8fae005 100644 --- a/etc/matrix-synapse/workers/federation_sender1_log_config.yaml +++ b/etc/matrix-synapse/workers/federation_sender1_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_federation_sender1.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/federation_sender2_log_config.yaml b/etc/matrix-synapse/workers/federation_sender2_log_config.yaml index 080ae2e..f10610f 100644 --- a/etc/matrix-synapse/workers/federation_sender2_log_config.yaml +++ b/etc/matrix-synapse/workers/federation_sender2_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_federation_sender2.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/federation_sender3_log_config.yaml b/etc/matrix-synapse/workers/federation_sender3_log_config.yaml index 1b6e6ce..8e8db54 100644 --- a/etc/matrix-synapse/workers/federation_sender3_log_config.yaml +++ b/etc/matrix-synapse/workers/federation_sender3_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_federation_sender3.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/generic_worker1_log_config.yaml b/etc/matrix-synapse/workers/generic_worker1_log_config.yaml index 4e6642b..ac13ef1 100644 --- a/etc/matrix-synapse/workers/generic_worker1_log_config.yaml +++ b/etc/matrix-synapse/workers/generic_worker1_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_generic_worker1.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/generic_worker2_log_config.yaml b/etc/matrix-synapse/workers/generic_worker2_log_config.yaml index b3a6914..1d46c3f 100644 --- a/etc/matrix-synapse/workers/generic_worker2_log_config.yaml +++ b/etc/matrix-synapse/workers/generic_worker2_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_generic_worker2.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/generic_worker3_log_config.yaml b/etc/matrix-synapse/workers/generic_worker3_log_config.yaml index 231f992..faa756f 100644 --- a/etc/matrix-synapse/workers/generic_worker3_log_config.yaml +++ b/etc/matrix-synapse/workers/generic_worker3_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_generic_worker3.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/generic_worker4_log_config.yaml b/etc/matrix-synapse/workers/generic_worker4_log_config.yaml index fad92ac..a2506d6 100644 --- a/etc/matrix-synapse/workers/generic_worker4_log_config.yaml +++ b/etc/matrix-synapse/workers/generic_worker4_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_generic_worker4.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/matrix-synapse/workers/pusher_log_config.yaml b/etc/matrix-synapse/workers/pusher_log_config.yaml index f1a68aa..b51e4ec 100644 --- a/etc/matrix-synapse/workers/pusher_log_config.yaml +++ b/etc/matrix-synapse/workers/pusher_log_config.yaml @@ -1,42 +1,84 @@ +# Log configuration for Synapse. +# +# This is a YAML file containing a standard Python logging configuration +# dictionary. See [1] for details on the valid settings. +# +# Synapse also supports structured logging for machine readable logs which can +# be ingested by ELK stacks. See [2] for details. +# +# [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema +# [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html + version: 1 formatters: precise: format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' -filters: - context: - (): synapse.util.logcontext.LoggingContextFilter - request: "" - handlers: file: - class: logging.handlers.RotatingFileHandler + class: logging.handlers.TimedRotatingFileHandler formatter: precise filename: /var/log/matrix-synapse/worker_pusher.log - maxBytes: 104857600 - backupCount: 5 - filters: [context] + when: midnight + backupCount: 3 # Does not include the current log file. encoding: utf8 + + # Default to buffering writes to log file for efficiency. + # WARNING/ERROR logs will still be flushed immediately, but there will be a + # delay (of up to `period` seconds, or until the buffer is full with + # `capacity` messages) before INFO/DEBUG logs get written. + buffer: + class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler + target: file + + # The capacity is the maximum number of log lines that are buffered + # before being written to disk. Increasing this will lead to better + # performance, at the expensive of it taking longer for log lines to + # be written to disk. + # This parameter is required. + capacity: 10 + + # Logs with a level at or above the flush level will cause the buffer to + # be flushed immediately. + # Default value: 40 (ERROR) + # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG) + flushLevel: 30 # Flush immediately for WARNING logs and higher + + # The period of time, in seconds, between forced flushes. + # Messages will not be delayed for longer than this time. + # Default value: 5 seconds + period: 5 + + # A handler that writes logs to stderr. Unused by default, but can be used + # instead of "buffer" and "file" in the logger handlers. console: class: logging.StreamHandler formatter: precise - filters: [context] loggers: - synapse: - level: WARN - synapse.storage.SQL: # beware: increasing this to DEBUG will make synapse log sensitive # information such as access tokens. level: WARN + twisted: + # We send the twisted logging directly to the file handler, + # to work around https://github.com/matrix-org/synapse/issues/3471 + # when using "buffer" logger. Use "console" to log to stderr instead. + handlers: [file] + propagate: false + root: level: WARN - handlers: [file, console] - precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s' + # Write logs to the `buffer` handler, which will buffer them together in memory, + # then write them to a file. + # + # Replace "buffer" with "console" to log to stderr instead. (Note that you'll + # also need to update the configuration for the `twisted` logger above, in + # this case.) + # + handlers: [buffer] disable_existing_loggers: false diff --git a/etc/nginx/include.d/generic_worker.conf b/etc/nginx/include.d/generic_worker.conf index cd1f64c..4de234f 100644 --- a/etc/nginx/include.d/generic_worker.conf +++ b/etc/nginx/include.d/generic_worker.conf @@ -7,270 +7,270 @@ # ## Sync requests -location ~* ^/_matrix/client/(v2_alpha|r0|v3)/sync$ { +location ~ ^/_matrix/client/(v2_alpha|r0|v3)/sync$ { include include.d/synapse-proxy.conf; proxy_pass http://localhost:8083; } -location ~* ^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$ { +location ~ ^/_matrix/client/(api/v1|v2_alpha|r0|v3)/events$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3)/initialSync$ { +location ~ ^/_matrix/client/(api/v1|r0|v3)/initialSync$ { include include.d/synapse-proxy.conf; proxy_pass http://localhost:8083; } -location ~* ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$ { +location ~ ^/_matrix/client/(api/v1|r0|v3)/rooms/[^/]+/initialSync$ { include include.d/synapse-proxy.conf; proxy_pass http://localhost:8083; } ## Federation requests -location ~* ^/_matrix/federation/v1/event/ { +location ~ ^/_matrix/federation/v1/event/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/state/ { +location ~ ^/_matrix/federation/v1/state/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/state_ids/ { +location ~ ^/_matrix/federation/v1/state_ids/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/backfill/ { +location ~ ^/_matrix/federation/v1/backfill/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/get_missing_events/ { +location ~ ^/_matrix/federation/v1/get_missing_events/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/publicRooms { +location ~ ^/_matrix/federation/v1/publicRooms { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/query/ { +location ~ ^/_matrix/federation/v1/query/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/make_join/ { +location ~ ^/_matrix/federation/v1/make_join/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/make_leave/ { +location ~ ^/_matrix/federation/v1/make_leave/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/send_join/ { +location ~ ^/_matrix/federation/v1/send_join/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v2/send_join/ { +location ~ ^/_matrix/federation/v2/send_join/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/send_leave/ { +location ~ ^/_matrix/federation/v1/send_leave/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v2/send_leave/ { +location ~ ^/_matrix/federation/v2/send_leave/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/invite/ { +location ~ ^/_matrix/federation/v1/invite/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v2/invite/ { +location ~ ^/_matrix/federation/v2/invite/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/query_auth/ { +location ~ ^/_matrix/federation/v1/query_auth/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/event_auth/ { +location ~ ^/_matrix/federation/v1/event_auth/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/exchange_third_party_invite/ { +location ~ ^/_matrix/federation/v1/exchange_third_party_invite/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/user/devices/ { +location ~ ^/_matrix/federation/v1/user/devices/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/v1/get_groups_publicised$ { +location ~ ^/_matrix/federation/v1/get_groups_publicised$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/key/v2/query { +location ~ ^/_matrix/key/v2/query { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/unstable/org.matrix.msc2946/spaces/ { +location ~ ^/_matrix/federation/unstable/org.matrix.msc2946/spaces/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/federation/(v1|unstable/org.matrix.msc2946)/hierarchy/ { +location ~ ^/_matrix/federation/(v1|unstable/org.matrix.msc2946)/hierarchy/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } ## Inbound federation transaction request -location ~* ^/_matrix/federation/v1/send/ { +location ~ ^/_matrix/federation/v1/send/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_ih; } ## Client API requests -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/createRoom$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/createRoom$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/publicRooms$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/publicRooms$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/joined_members$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/joined_members$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/context/.*$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/members$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/unstable/org.matrix.msc2946/rooms/.*/spaces$ { +location ~ ^/_matrix/client/unstable/org.matrix.msc2946/rooms/.*/spaces$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(v1|unstable/org.matrix.msc2946)/rooms/.*/hierarchy$ { +location ~ ^/_matrix/client/(v1|unstable/org.matrix.msc2946)/rooms/.*/hierarchy$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$ { +location ~ ^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/account/3pid$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/devices$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/devices$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/query$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/query$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/changes$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/keys/changes$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/versions$ { +location ~ ^/_matrix/client/versions$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/voip/turnServer$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_groups$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_groups$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups/ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event/ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/search$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/search$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } ## Registration/login requests -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/login$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/login$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/(r0|v3|unstable)/register$ { +location ~ ^/_matrix/client/(r0|v3|unstable)/register$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } -location ~* ^/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity$ { +location ~ ^/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc; } @@ -278,72 +278,72 @@ location ~* ^/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc # STREAM WORKERS ## Event sending requests -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/redact { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/redact { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc_instancemap; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/send { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/send { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc_instancemap; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state/ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/state/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc_instancemap; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/(join|invite|leave|ban|unban|kick)$ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc_instancemap; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/join/ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/join/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc_instancemap; } -location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/profile/ { +location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/profile/ { include include.d/synapse-proxy.conf; proxy_pass http://generic_worker_lc_instancemap; } ## Typing requests -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/typing { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/typing { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} ## Device requests -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/sendToDevice/ { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/sendToDevice/ { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} ## Account data requests -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/.*/tags { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/.*/tags { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/.*/account_data { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/.*/account_data { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} ## Receipts requests -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/receipt { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/receipt { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/read_markers { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/read_markers { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} ## Presence requests -#location ~* ^/_matrix/client/(api/v1|r0|v3|unstable)/presence/.*/status$ { +#location ~ ^/_matrix/client/(api/v1|r0|v3|unstable)/presence/.*/status$ { # include include.d/synapse-proxy.conf; # proxy_pass http://generic_worker_lc_instancemap; #} diff --git a/etc/nginx/sites-available/matrix.envs.net.conf b/etc/nginx/sites-available/matrix.envs.net.conf index 66fedce..0468499 100644 --- a/etc/nginx/sites-available/matrix.envs.net.conf +++ b/etc/nginx/sites-available/matrix.envs.net.conf @@ -13,17 +13,6 @@ server { } -map $http_origin $DO_CORS { - # indicates all map values are hostnames and should be parsed as such - hostnames; - # default value - default 'true'; - # blocked domains - renaissance.eu.org 'false'; - element.renaissance.eu.org 'false'; -} - - # WORKERS upstream generic_worker_ih { ip_hash; @@ -57,17 +46,21 @@ server { ## well-known location /.well-known/matrix/support { -# add_header Access-Control-Allow-Origin "$DO_CORS"; add_header Access-Control-Allow-Origin '*' always; add_header Content-Type application/json; return 200 '{"admins": [{"matrix_id": "@creme:envs.net", "email_address": "hostmaster@envs.net", "role": "admin"}], "support_page": "https://matrix.to/#/#envs:envs.net"}'; } - location /.well-known/matrix { -# add_header Access-Control-Allow-Origin "$DO_CORS"; + location /.well-known/matrix/server { add_header Access-Control-Allow-Origin '*' always; add_header Content-Type application/json; - return 200 '{"m.server": "matrix.envs.net:443", "m.homeserver": {"base_url": "https://matrix.envs.net"}, "m.integrations": {"managers": [{"ui_url": "https://dimension.envs.net/riot", "api_url": "https://dimension.envs.net/api/v1/scalar"}, {"ui_url": "https://scalar.vector.im/", "api_url": "https://scalar.vector.im/api"}]}, "m.integrations_widget": {"url": "https://dimension.envs.net/riot", "data": {"api_url": "https://dimension.envs.net/api/v1/scalar"}}}'; + return 200 '{"m.server": "matrix.envs.net:443"}'; + } + + location /.well-known/matrix/client { + add_header Access-Control-Allow-Origin '*' always; + add_header Content-Type application/json; + return 200 '{"m.homeserver": {"base_url": "https://matrix.envs.net"}, "m.integrations": {"managers": [{"ui_url": "https://dimension.envs.net/riot", "api_url": "https://dimension.envs.net/api/v1/scalar"}, {"ui_url": "https://scalar.vector.im/", "api_url": "https://scalar.vector.im/api"}]}, "m.integrations_widget": {"url": "https://dimension.envs.net/riot", "data": {"api_url": "https://dimension.envs.net/api/v1/scalar"}}}'; } # workers @@ -96,3 +89,16 @@ server { proxy_pass http://localhost:8008; } } + +server { + listen 8448 ssl http2; + listen [::]:8448 ssl http2; + server_name matrix.envs.net; + + include snippets/ssl.conf; + + location / { + include include.d/synapse-proxy.conf; + proxy_pass http://localhost:8008; + } +} diff --git a/etc/systemd/system/matrix-media.service b/etc/systemd/system/matrix-media.service index 944194b..447177f 100644 --- a/etc/systemd/system/matrix-media.service +++ b/etc/systemd/system/matrix-media.service @@ -1,6 +1,9 @@ [Unit] Description=matrix-media-repo -After=network.target postgresql@13-main.service matrix-synapse.service redis-server.service +After=network.target +Requires=postgresql@13-main.service +Requires=matrix-synapse.target +Requires=redis-server.service [Service] Type=simple diff --git a/etc/systemd/system/matrix-synchrotron-balancer.service b/etc/systemd/system/matrix-synchrotron-balancer.service index 82167ff..df2b9e9 100644 --- a/etc/systemd/system/matrix-synchrotron-balancer.service +++ b/etc/systemd/system/matrix-synchrotron-balancer.service @@ -1,6 +1,8 @@ [Unit] Description=matrix-synchrotron-balancer -After=network.target matrix-synapse.service +After=network.target +Requires=nginx.service +Requires=matrix-synapse.target [Service] Type=simple