2019-05-07 19:23:35 +00:00
|
|
|
#jinja2: lstrip_blocks: "True"
|
2019-01-27 18:25:13 +00:00
|
|
|
# This is a custom nginx configuration file that we use in the container (instead of the default one),
|
|
|
|
# because it allows us to run nginx with a non-root user.
|
|
|
|
#
|
|
|
|
# For this to work, the default vhost file (`/etc/nginx/conf.d/default.conf`) also needs to be removed.
|
|
|
|
#
|
|
|
|
# The following changes have been done compared to a default nginx configuration file:
|
|
|
|
# - various temp paths are changed to `/tmp`, so that a non-root user can write to them
|
|
|
|
# - the `user` directive was removed, as we don't want nginx to switch users
|
|
|
|
|
2021-03-02 10:30:09 +00:00
|
|
|
worker_processes {{ matrix_nginx_proxy_worker_processes }};
|
2019-01-27 18:25:13 +00:00
|
|
|
error_log /var/log/nginx/error.log warn;
|
|
|
|
pid /tmp/nginx.pid;
|
2021-03-30 14:41:32 +00:00
|
|
|
{% for configuration_block in matrix_nginx_proxy_proxy_additional_configuration_blocks %}
|
2021-03-30 12:11:20 +00:00
|
|
|
{{- configuration_block }}
|
|
|
|
{% endfor %}
|
2019-01-27 18:25:13 +00:00
|
|
|
|
|
|
|
events {
|
2021-03-02 10:30:09 +00:00
|
|
|
worker_connections {{ matrix_nginx_proxy_worker_connections }};
|
2021-03-30 14:41:32 +00:00
|
|
|
{% for configuration_block in matrix_nginx_proxy_proxy_event_additional_configuration_blocks %}
|
2021-03-30 12:11:20 +00:00
|
|
|
{{- configuration_block }}
|
|
|
|
{% endfor %}
|
2019-01-27 18:25:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
http {
|
|
|
|
proxy_temp_path /tmp/proxy_temp;
|
|
|
|
client_body_temp_path /tmp/client_temp;
|
|
|
|
fastcgi_temp_path /tmp/fastcgi_temp;
|
|
|
|
uwsgi_temp_path /tmp/uwsgi_temp;
|
|
|
|
scgi_temp_path /tmp/scgi_temp;
|
|
|
|
|
|
|
|
include /etc/nginx/mime.types;
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
|
2020-12-20 16:30:28 +00:00
|
|
|
{% if matrix_nginx_proxy_access_log_enabled %}
|
2019-01-27 18:25:13 +00:00
|
|
|
access_log /var/log/nginx/access.log main;
|
2022-12-07 14:58:36 +00:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if matrix_nginx_proxy_access_log_syslog_integration_enabled %}
|
|
|
|
log_format prometheus_fmt 'matrix-nginx-proxy $server_name - $upstream_addr - $remote_addr - $remote_user [$time_local] '
|
|
|
|
'$host "$request" '
|
|
|
|
'$status "$http_referer" '
|
|
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
|
|
|
|
access_log syslog:server={{ matrix_nginx_proxy_access_log_syslog_integration_server_port }},tag=matrix_nginx_proxy prometheus_fmt;
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if not matrix_nginx_proxy_access_log_enabled and not matrix_nginx_proxy_access_log_syslog_integration_enabled %}
|
2020-12-20 16:30:28 +00:00
|
|
|
access_log off;
|
|
|
|
{% endif %}
|
2022-11-20 14:43:30 +00:00
|
|
|
|
2021-09-03 07:00:45 +00:00
|
|
|
proxy_connect_timeout {{ matrix_nginx_proxy_connect_timeout }};
|
2022-11-20 14:43:30 +00:00
|
|
|
proxy_send_timeout {{ matrix_nginx_proxy_send_timeout }};
|
2021-09-03 07:00:45 +00:00
|
|
|
proxy_read_timeout {{ matrix_nginx_proxy_read_timeout }};
|
|
|
|
send_timeout {{ matrix_nginx_send_timeout }};
|
2019-01-27 18:25:13 +00:00
|
|
|
|
|
|
|
sendfile on;
|
|
|
|
#tcp_nopush on;
|
|
|
|
|
|
|
|
keepalive_timeout 65;
|
|
|
|
|
2021-04-18 14:24:13 +00:00
|
|
|
server_tokens off;
|
|
|
|
|
2019-01-27 18:25:13 +00:00
|
|
|
#gzip on;
|
2021-01-21 12:32:25 +00:00
|
|
|
{# Map directive needed for proxied WebSocket upgrades #}
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
default upgrade;
|
|
|
|
'' close;
|
|
|
|
}
|
2019-01-27 18:25:13 +00:00
|
|
|
|
|
|
|
include /etc/nginx/conf.d/*.conf;
|
|
|
|
}
|