diff --git a/README-containers.md b/README-containers.md index 21ecea3e..ed425238 100644 --- a/README-containers.md +++ b/README-containers.md @@ -103,142 +103,163 @@ An example can be seen in the [docker-compose](https://github.com/coreruleset/mo > 💬 What happens if I want to make changes in a different file, like `/etc/nginx/conf.d/default.conf`? > You mount your local file, e.g. `nginx/default.conf` as the new template: `/etc/nginx/templates/conf.d/default.conf.template`. You can do this similarly with other files. Files in the templates directory will be copied and subdirectories will be preserved. -### Common ENV Variables - -These variables are common to image variants and will set defaults based on the image name. -| Name | Description| -| -- | -- | -| ACCESSLOG | Location of the custom log file (Default: `/var/log/apache2/access.log` and `/var/log/nginx/access.log`) | -| BACKEND | Partial URL for the remote server of the `ProxyPass` and `proxy_pass` directive (Default: `http://localhost:80`) | -| ERRORLOG | Location of the error log file (Default: `/proc/self/fd/2`) | -| LOGLEVEL | Number of messages logged to the error_log (Default: `warn`) | -| METRICS_ALLOW_FROM | a single range of IP adresses that can access the metrics (Default: `127.0.0.0/24` and `127.0.0.0/255.0.0.0 ::1/128`) | -| METRICS_DENY_FROM | a range of IP adresses that cannot access the metrics (Default: `all` and `All`) | -| PORT | An int value indicating the port where the webserver is listening to (Default: `80`) | -| PROXY_SSL_CERT | Path to the server PEM-encoded X.509 certificate data file or token identifier (Default: `/usr/local/apache2/conf/server.crt` and `/etc/nginx/conf/server.crt`) | -| PROXY_SSL_CERT_KEY | Path to the server PEM-encoded private key file (Default: `/etc/nginx/conf/server.key` and `/usr/local/apache2/conf/server.key`) | -| PROXY_SSL_VERIFY | Type of remote server Certificate verification (Default: `none` and `off`) | -| SSL_PORT | Port number where the SSL enabled webserver is listening (Default: `443`) | -| TIMEOUT | Number of seconds before receiving and sending timeout (Default: `60`) | - ### Apache ENV Variables -| Name | Description| -| -- | -- | -| APACHE_ALWAYS_TLS_REDIRECT | if http should redirect to https (Allowed values: `on`, `off`. Default: `off`) | -| APACHE_LOGFORMAT | The LogFormat that apache should use. (Default: `'"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""'` (combined). Tip: use single quotes outside your double quoted format string.) ⚠️ Do not add a `|` as part of the log format. It is used internally. | -| APACHE_METRICS_LOGFORMAT | The LogFormat that the additional log apache metrics should use. (Default:'"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""' (combined). Tip: use single quotes outside your double quoted format string.) ⚠️ Do not add a `|` as part of the log format. It is used internally. | -| BACKEND_WS | The IP/URL of the WebSocket service (Default: `ws://localhost:8080`) | -| H2_PROTOCOLS | Protocols supported by the HTTP2 module (Default: `h2 http/1.1`) | -| METRICSLOG | Path of the metrics log (Default: `/dev/null`) | +| Name | Description| +| -------- | ------------------------------------------------------------------- | +| ACCESSLOG | A string value indicating the location of the custom log file (Default: `/var/log/apache2/access.log`) | +| APACHE_ALWAYS_TLS_REDIRECT | A string value indicating if http should redirect to https (Allowed values: `on`, `off`. Default: `off`) | +| APACHE_LOGFORMAT | A string value indicating the LogFormat that apache should use. (Default: `'"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""'` (combined). Tip: use single quotes outside your double quoted format string.) ⚠️ Do not add a `|` as part of the log format. It is used internally. | +| APACHE_ERRORLOG_FORMAT | A string value indicating the `ErrorLogFormat` that Apache should use. (Default: `'"[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i"'` | +| APACHE_METRICS_LOGFORMAT | A string value indicating the LogFormat that the additional log apache metrics should use. (Default:'"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""' (combined). Tip: use single quotes outside your double quoted format string.) ⚠️ Do not add a `|` as part of the log format. It is used internally. | +| BACKEND | A string indicating the partial URL for the remote server of the `ProxyPass` directive (Default: `http://localhost:80`) | +| BACKEND_WS | A string indicating the IP/URL of the WebSocket service (Default: `ws://localhost:8080`) | +| ERRORLOG | A string value indicating the location of the error log file (Default: `/var/log/apache2/error.log`) | +| H2_PROTOCOLS | A string value indicating the protocols supported by the HTTP2 module (Default: `h2 http/1.1`) | +| LOGLEVEL | A string value controlling the number of messages logged to the error_log (Default: `warn`) | +| METRICS_ALLOW_FROM | A string indicating a range of IP adresses that can access the metrics (Default: `127.0.0.0/255.0.0.0 ::1/128`) | +| METRICS_DENY_FROM | A string indicating a range of IP adresses that cannot access the metrics (Default: `All`) | +| METRICSLOG | A string indicating the path of the metrics log (Default: `/dev/null`) | | MUTEX | Configure mutex and lock file directory for all specified mutexes (see [Mutex](https://httpd.apache.org/docs/2.4/mod/core.html#mutex)) (Default: `default`) | -| PROXY_ERROR_OVERRIDE | that errors from the backend services should be overridden by this proxy server (see [ProxyErrorOverride](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxyerroroverride) directive). (Allowed values: `on`, `off`. Default: `on`) | -| PROXY_PRESERVE_HOST | Use of incoming Host HTTP request header for proxy request (Default: `on`) | -| PROXY_SSL_CHECK_PEER_NAME | if the host name checking for remote server certificates is to be enabled (Default: `on`) | -| PROXY_SSL | A string with SSL Proxy Engine Operation Switch (Default: `off`) | -| PROXY_TIMEOUT | Number of seconds for proxied requests to time out (Default: `60`) | -| REMOTEIP_INT_PROXY | Client intranet IP addresses trusted to present the RemoteIPHeader value (Default: `10.1.0.0/16`) | -| REQ_HEADER_FORWARDED_PROTO | Transfer protocol of the initial request (Default: `https`) | -| SERVER_ADMIN | Address where problems with the server should be e-mailed (Default: `root@localhost`) | -| SERVER_NAME | Server name (Default: `localhost`) | -| SSL_CIPHER_SUITE | Cipher suite to use. Uses OpenSSL [list of cipher suites](https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ciphersuites.html) (Default: `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | -| SSL_ENGINE | The SSL Engine Operation Switch (Default: `on`) | -| SSL_HONOR_CIPHER_ORDER | if the server should [honor the cipher list provided by the client](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslhonorcipherorder) (Allowed values: `on`, `off`. Default: `off`) | +| PORT | An integer value indicating the port where the webserver is listening to (Default: `80`) | +| PROXY_ERROR_OVERRIDE | A string indicating that errors from the backend services should be overridden by this proxy server (see [ProxyErrorOverride](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxyerroroverride) directive). (Allowed values: `on`, `off`. Default: `on`) | +| PROXY_PRESERVE_HOST | A string indicating the use of incoming Host HTTP request header for proxy request (Default: `on`) | +| PROXY_SSL | A string indicating SSL Proxy Engine Operation Switch (Default: `on`) | +| PROXY_SSL_CA_CERT | A string indicating the path to the PEM-encoded list of accepted CA certificates for the proxied server (Default: `/etc/ssl/certs/ca-certificates.ca`) | +| PROXY_SSL_CERT | A string indicating the path to the PEM-encoded X.509 certificate data file or token identifier of the proxied server (Default: `/usr/local/apache2/conf/proxy.crt`) | +| PROXY_SSL_CERT_KEY | A string indicating the path to the PEM-encoded private key file of the proxied server (Default: `/usr/local/apache2/conf/proxy.key`) | +| PROXY_SSL_CHECK_PEER_NAME | A string indicating if the host name checking for remote server certificates is to be enabled (Default: `on`) | +| PROXY_SSL_CIPHER_SUITE | A string indicating the cipher suite to connect to the backend via TLS. (Default `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | +| PROXY_SSL_PROTOCOL | A string for configuring the [proxy client SSL/TLS protocol versions](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslproxyprotocol) (Default: `"all -SSLv3 -TLSv1 -TLSv1.1"`) | +| PROXY_SSL_VERIFY | A string value indicating the type of remote server Certificate verification (Default: `none`) | +| PROXY_TIMEOUT | Number of seconds for proxied requests to time out (Default: `60`) | +| REMOTEIP_INT_PROXY | A string indicating the client intranet IP addresses trusted to present the RemoteIPHeader value (Default: `10.1.0.0/16`) | +| REQ_HEADER_FORWARDED_PROTO | A string indicating the transfer protocol of the initial request (Default: `https`) | +| SERVER_ADMIN | A string value indicating the address where problems with the server should be e-mailed (Default: `root@localhost`) | +| SERVER_NAME | A string value indicating the server name (Default: `localhost`) | +| SERVER_SIGNATURE | A string value configuring the footer on server-generated documents (Allowed values: `On`, `Off`, `EMail`. Default: `Off`) | +| SERVER_TOKENS | Option defining the server information presented to clients in the `Server` HTTP response header. Also see `MODSEC_SERVER_SIGNATURE`. (Allowed values: `Full`, `Prod[uctOnly]`, `Major`, `Minor`, `Min[imal]`, `OS`. Default: `Full`). | +| SSL_CERT | A string indicating the path to the PEM-encoded X.509 certificate data file or token identifier of the server (Default: `/usr/local/apache2/conf/proxy.crt`) | +| SSL_CERT_KEY | A string indicating the path to the PEM-encoded private key file of the server (Default: `/usr/local/apache2/conf/proxy.key`) | +| SSL_CIPHER_SUITE | A string indicating the cipher suite to use. Uses OpenSSL [list of cipher suites](https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ciphersuites.html) (Default: `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | +| SSL_ENGINE | A string indicating the SSL Engine Operation Switch (Default: `on`) | +| SSL_HONOR_CIPHER_ORDER | A string indicating if the server should [honor the cipher list provided by the client](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslhonorcipherorder) (Allowed values: `on`, `off`. Default: `off`) | +| SSL_PORT | Port number where the SSL enabled webserver is listening (Default: `443`) | | SSL_PROTOCOL | A string for configuring the [usable SSL/TLS protocol versions](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslprotocol) (Default: `"all -SSLv3 -TLSv1 -TLSv1.1"`) | -| SSL_PROXY_PROTOCOL | A string for configuring the [proxy client SSL/TLS protocol versions](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslproxyprotocol) (Default: `"all -SSLv3 -TLSv1 -TLSv1.1"`) | -| SSL_PROXY_CIPHER_SUITE | Cipher suite to connect to the backend via TLS. (Default `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | | SSL_SESSION_TICKETS | A string to enable or disable the use of [TLS session tickets](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslsessiontickets) (RFC 5077). (Default: `off`) | -| SSL_USE_STAPLING | if [OSCP Stapling](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslusestapling) should be used (Allowed values: `on`, `off`. Default: `on`) | -| WORKER_CONNECTIONS | Maximum number of MPM request worker processes (Default: `400`) | +| SSL_USE_STAPLING | A string indicating if [OSCP Stapling](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslusestapling) should be used (Allowed values: `on`, `off`. Default: `on`) | +| TIMEOUT | Number of seconds before receiving and sending timeout (Default: `60`) | +| WORKER_CONNECTIONS | Maximum number of MPM request worker processes (Default: `400`) | Note: Apache access and metric logs can be disabled by exporting the `nologging=1` environment variable, or using `ACCESSLOG=/dev/null` and `METRICSLOG=/dev/null`. ### Nginx ENV Variables -| Name | Description| -| -- | -- | -| DNS_SERVER | Name servers used to resolve names of upstream servers into addresses. For localhost backend this value should not be defined (Default: _not defined_) | -| METRICSLOG | Location of metrics log file (Default: `/dev/null`) | -| NGINX_ALWAYS_TLS_REDIRECT | if http should redirect to https (Allowed values: `on`, `off`. Default: `off`) | +| Name | Description| +| -------- | ------------------------------------------------------------------- | +| ACCESSLOG | A string value indicating the location of the access log file (Default: `/var/log/nginx/access.log`) | +| BACKEND | A string indicating the partial URL for the remote server of the `proxy_pass` directive (Default: `http://localhost:80`) | +| DNS_SERVER | A string indicating the name servers used to resolve names of upstream servers into addresses. For localhost backend this value should not be defined (Default: _not defined_) | +| ERRORLOG | A string value indicating the location of the error log file (Default: `/proc/self/fd/2`) | +| LOGLEVEL | A string value controlling the number of messages logged to the error_log (Default: `warn`) | +| METRICS_ALLOW_FROM | A string indicating a single range of IP adresses that can access the metrics (Default: `127.0.0.0/24`) | +| METRICS_DENY_FROM | A string indicating a range of IP adresses that cannot access the metrics (Default: `all`) | +| METRICSLOG | A string value indicating the location of metrics log file (Default: `/dev/null`) | +| NGINX_ALWAYS_TLS_REDIRECT | A string value indicating if http should redirect to https (Allowed values: `on`, `off`. Default: `off`) | +| PORT | An integer value indicating the port where the webserver is listening to (Default: `80`) | | SET_REAL_IP_FROM | A string of comma separated IP, CIDR, or UNIX domain socket addresses that are trusted to replace addresses in `REAL_IP_HEADER` (Default: `127.0.0.1`). See [set_real_ip_from](http://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from) | | REAL_IP_HEADER | Name of the header containing the real IP value(s) (Default: `X-REAL-IP`). See [real_ip_header](http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_header) | | REAL_IP_PROXY_HEADER | Name of the header containing `$remote_addr` to be passed to proxy (Default: `X-REAL-IP`). See [proxy_set_header](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header) | -| REAL_IP_RECURSIVE | whether to use recursive reaplacement on addresses in `REAL_IP_HEADER` (Allowed values: `on`, `off`. Default: `on`). See [real_ip_recursive](http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive) | +| REAL_IP_RECURSIVE | A string value indicating whether to use recursive reaplacement on addresses in `REAL_IP_HEADER` (Allowed values: `on`, `off`. Default: `on`). See [real_ip_recursive](http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive) | +| PROXY_SSL | A string indicating SSL Proxy Engine Operation Switch (Default: `on`) | +| PROXY_SSL_CERT | A string value indicating the path to the server PEM-encoded X.509 certificate data file or token value identifier (Default: `/etc/nginx/conf/server.crt`) | +| PROXY_SSL_CERT_KEY | A string value indicating the path to the server PEM-encoded private key file (Default: `/etc/nginx/conf/server.key`) | | PROXY_SSL_CIPHERS | A String value indicating the enabled ciphers. The ciphers are specified in the format understood by the OpenSSL library. (Default: `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;`| -| PROXY_SSL_DH_BITS | A numeric value indicating the size (in bits) to use for the generated DH-params file (Default 2048) | -| PROXY_SSL_OCSP_STAPLING | if ssl_stapling and ssl_stapling_verify should be enabled (Allowed values: `on`, `off`. Default: `off`) | -| PROXY_SSL_PREFER_CIPHERS | if the server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols (Allowed values: `on`, `off`. Default: `off`)| -| PROXY_SSL_PROTOCOLS | Ssl protocols to enable (default: `TTLSv1.2 TLSv1.3`)| -| PROXY_TIMEOUT | Number of seconds for proxied requests to time out connections (Default: `60s`) | -| WORKER_CONNECTIONS | Maximum number of simultaneous connections that can be opened by a worker process (Default: `1024`) | +| PROXY_SSL_PROTOCOLS | A string value indicating the ssl protocols to enable (default: `TTLSv1.2 TLSv1.3`)| +| PROXY_SSL_VERIFY | A string value indicating if the client certificates should be verified (Allowed values: `on`, `off`. Default: `off`) | +| PROXY_SSL_VERIFY_DEPTH | An integer value indicating the verification depth for the client certificate chain (Default: `1`) | +| PROXY_TIMEOUT | Number of seconds for proxied requests to time out connections (Default: `60s`) | +| SERVER_NAME | A string value indicating the server name (Default: `localhost`) | +| SERVER_TOKENS | A boolean value for enabling / disabling emission of server identifying information in the `Server` HTTP response header and on error pages. (Allowed values: `on`, `off`, `build`. Default: `off`). | +| SSL_CERT | A string value indicating the path to the server PEM-encoded X.509 certificate data file or token value identifier (Default: `/etc/nginx/conf/server.crt`) | +| SSL_CERT_KEY | A string value indicating the path to the server PEM-encoded private key file (Default: `/etc/nginx/conf/server.key`) | +| SSL_CIPHERS | A String value indicating the enabled ciphers. The ciphers are specified in the format understood by the OpenSSL library. (Default: `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;`| +| SSL_DH_BITS | A numeric value indicating the size (in bits) to use for the generated DH-params file (Default 2048) | +| SSL_OCSP_STAPLING | A string value indicating if ssl_stapling and ssl_stapling_verify should be enabled (Allowed values: `on`, `off`. Default: `off`) | +| SSL_PORT | Port number where the SSL enabled webserver is listening (Default: `443`) | +| SSL_PREFER_CIPHERS | A string value indicating if the server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols (Allowed values: `on`, `off`. Default: `off`)| +| SSL_PROTOCOLS | A string value indicating the ssl protocols to enable (default: `TTLSv1.2 TLSv1.3`)| +| SSL_VERIFY | A string value indicating if the client certificates should be verified (Allowed values: `on`, `off`. Default: `off`) | +| SSL_VERIFY_DEPTH | An integer value indicating the verification depth for the client certificate chain (Default: `1`) | +| TIMEOUT | Number of seconds for a keep-alive client connection to stay open on the server side (Default: `60s`) | +| WORKER_CONNECTIONS | Maximum number of simultaneous connections that can be opened by a worker process (Default: `1024`) | + +### Openresty ENV Variables + +Openresty uses the same environment variables as the nginx version. ### ModSecurity ENV Variables -All these variables impact in configuration directives in the modsecurity engine running inside the container. +All these variables impact in configuration directives in the modsecurity engine running inside the container. The [reference manual](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)) has the extended documentation, and for your reference we list the specific directive we change when you modify the ENV variables for the container. -| Name | Description| +| Name | Description| | -------- | ------------------------------------------------------------------- | -| MODSEC_AUDIT_ENGINE | A string used to configure the audit engine, which logs complete transactions (Default: `RelevantOnly`). Accepted values: `On`, `Off`, `RelevantOnly`. See [SecAuditEngine](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecAuditEngine) for additional information. | -| MODSEC_AUDIT_LOG | Path to the main audit log file or the concurrent logging index file (Default: `/dev/stdout`) | -| MODSEC_AUDIT_LOG_FORMAT | Output format of the AuditLogs (Default: `JSON`). Accepted values: `JSON`, `Native`. See [SecAuditLogFormat](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecAuditLogFormat) for additional information. | -| MODSEC_AUDIT_LOG_TYPE | Type of audit logging mechanism to be used (Default: `Serial`). Accepted values: `Serial`, `Concurrent` (`HTTPS` works only on Nginx - v3). See [SecAuditLogType](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secauditlogtype) for additional information. | -| MODSEC_AUDIT_LOG_PARTS | A string that defines which parts of each transaction are going to be recorded in the audit log (Default: `'ABIJDEFHZ'`). See [SecAuditLogParts](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secauditlogparts) for the accepted values. | -| MODSEC_AUDIT_STORAGE | Directory where concurrent audit log entries are to be stored (Default: `/var/log/modsecurity/audit/`) | -| MODSEC_DATA_DIR | Path where persistent data (e.g., IP address data, session data, and so on) is to be stored (Default: `/tmp/modsecurity/data`) | -| MODSEC_DEBUG_LOG | Path to the ModSecurity debug log file (Default: `/dev/null`) | -| MODSEC_DEBUG_LOGLEVEL | An int indicating the verboseness of the debug log data (Default: `0`). Accepted values: `0` - `9`. See [SecDebugLogLevel](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secdebugloglevel). | -| MODSEC_DISABLE_BACKEND_COMPRESSION | whether or not to disable backend compression (Default: `On`). Allowed values: `On`, `Off`. See [SecDisableBackendCompression](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secdisablebackendcompression) for more. Only supported in ModSecurity 2.x, will have not effect on 3.x | -| MODSEC_PCRE_MATCH_LIMIT | An int value indicating the limit for the number of internal executions in the PCRE function (Default: `100000`) (Only valid for Apache - v2). See [SecPcreMatchLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#SecPcreMatchLimit) | -| MODSEC_PCRE_MATCH_LIMIT_RECURSION | An int value indicating the limit for the depth of recursion when calling PCRE function (Default: `100000`) | -| MODSEC_REQ_BODY_ACCESS | A string allowing ModSecurity to access request bodies (Default: `On`). Allowed values: `On`, `Off`. See [SecRequestBodyAccess](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodyaccess) for more information. | -| MODSEC_REQ_BODY_LIMIT | An int value indicating the maximum request body size accepted for buffering (Default: `13107200`). See [SecRequestBodyLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodylimit) for additional information. | -| MODSEC_REQ_BODY_LIMIT_ACTION | A string for the action when `SecRequestBodyLimit` is reached (Default: `Reject`). Accepted values: `Reject`, `ProcessPartial`. See [SecRequestBodyLimitAction](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodylimitaction) for additional information. | -| MODSEC_REQ_BODY_JSON_DEPTH_LIMIT | An int value indicating the maximun JSON request depth (Default: `512`). See [SecRequestBodyJsonDepthLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecRequestBodyJsonDepthLimit) for additional information. | -| MODSEC_REQ_BODY_NOFILES_LIMIT | An int indicating the maximum request body size ModSecurity will accept for buffering (Default: `131072`). See [SecRequestBodyNoFilesLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodynofileslimit) for more information. | -| MODSEC_RESP_BODY_ACCESS | A string allowing ModSecurity to access response bodies (Default: `On`). Allowed values: `On`, `Off`. See [SecResponseBodyAccess](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secresponsebodyaccess) for more information. | -| MODSEC_RESP_BODY_LIMIT | An int value indicating the maximum response body size accepted for buffering (Default: `1048576`) | -| MODSEC_RESP_BODY_LIMIT_ACTION | A string for the action when `SecResponseBodyLimit` is reached (Default: `ProcessPartial`). Accepted values: `Reject`, `ProcessPartial`. See [SecResponseBodyLimitAction](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secresponsebodylimitaction) for additional information. | -| MODSEC_RESP_BODY_MIMETYPE | List of mime types that will be analyzed in the response (Default: `'text/plain text/html text/xml'`). You might consider adding `application/json` documented [here](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-\(v2.x\)#secresponsebodymimetype). | -| MODSEC_RULE_ENGINE | A string enabling ModSecurity itself (Default: `On`). Accepted values: `On`, `Off`, `DetectionOnly`. See [SecRuleEngine](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secruleengine) for additional information. | -| MODSEC_STATUS_ENGINE | A string used to configure the status engine, which sends statistical information (Default: `Off`). Accepted values: `On`, `Off`. See [SecStatusEngine](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecStatusEngine) for additional information. | -| MODSEC_TAG | Default tag action, which will be inherited by the rules in the same configuration context (Default: `modsecurity`) | -| MODSEC_TMP_DIR | Path where temporary files will be created (Default: `/tmp/modsecurity/tmp`) | -| MODSEC_TMP_SAVE_UPLOADED_FILES | if temporary uploaded files are saved (Default: `On`) (only relevant in Apache - ModSecurity v2) | -| MODSEC_UPLOAD_DIR | Path where intercepted files will be stored (Default: `/tmp/modsecurity/upload`) | +| MODSEC_AUDIT_ENGINE | A string used to configure the audit engine, which logs complete transactions (Default: `RelevantOnly`). Accepted values: `On`, `Off`, `RelevantOnly`. See [SecAuditEngine](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecAuditEngine) for additional information. | +| MODSEC_AUDIT_LOG | A string indicating the path to the main audit log file or the concurrent logging index file (Default: `/dev/stdout`) | +| MODSEC_AUDIT_LOG_FORMAT | A string indicating the output format of the AuditLogs (Default: `JSON`). Accepted values: `JSON`, `Native`. See [SecAuditLogFormat](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecAuditLogFormat) for additional information. | +| MODSEC_AUDIT_LOG_TYPE | A string indicating the type of audit logging mechanism to be used (Default: `Serial`). Accepted values: `Serial`, `Concurrent` (`HTTPS` works only on Nginx - v3). See [SecAuditLogType](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secauditlogtype) for additional information. | +| MODSEC_AUDIT_LOG_PARTS | A string that defines which parts of each transaction are going to be recorded in the audit log (Default: `'ABIJDEFHZ'`). See [SecAuditLogParts](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secauditlogparts) for the accepted values. | +| MODSEC_AUDIT_STORAGE | A string indicating the directory where concurrent audit log entries are to be stored (Default: `/var/log/modsecurity/audit/`) | +| MODSEC_DATA_DIR | A string indicating the path where persistent data (e.g., IP address data, session data, and so on) is to be stored (Default: `/tmp/modsecurity/data`) | +| MODSEC_DEBUG_LOG | A string indicating the path to the ModSecurity debug log file (Default: `/dev/null`) | +| MODSEC_DEBUG_LOGLEVEL | An integer indicating the verboseness of the debug log data (Default: `0`). Accepted values: `0` - `9`. See [SecDebugLogLevel](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secdebugloglevel). | +| MODSEC_DISABLE_BACKEND_COMPRESSION | A string indicating whether or not to disable backend compression (Default: `On`). Allowed values: `On`, `Off`. See [SecDisableBackendCompression](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secdisablebackendcompression) for more. Only supported in ModSecurity 2.x, will have not effect on 3.x | +| MODSEC_PCRE_MATCH_LIMIT | An integer value indicating the limit for the number of internal executions in the PCRE function (Default: `100000`) (Only valid for Apache - v2). See [SecPcreMatchLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#SecPcreMatchLimit) | +| MODSEC_PCRE_MATCH_LIMIT_RECURSION | An integer value indicating the limit for the depth of recursion when calling PCRE function (Default: `100000`) | +| MODSEC_REQ_BODY_ACCESS | A string value allowing ModSecurity to access request bodies (Default: `On`). Allowed values: `On`, `Off`. See [SecRequestBodyAccess](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodyaccess) for more information. | +| MODSEC_REQ_BODY_LIMIT | An integer value indicating the maximum request body size accepted for buffering (Default: `13107200`). See [SecRequestBodyLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodylimit) for additional information. | +| MODSEC_REQ_BODY_LIMIT_ACTION | A string value for the action when `SecRequestBodyLimit` is reached (Default: `Reject`). Accepted values: `Reject`, `ProcessPartial`. See [SecRequestBodyLimitAction](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodylimitaction) for additional information. | +| MODSEC_REQ_BODY_JSON_DEPTH_LIMIT | An integer value indicating the maximun JSON request depth (Default: `512`). See [SecRequestBodyJsonDepthLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecRequestBodyJsonDepthLimit) for additional information. | +| MODSEC_REQ_BODY_NOFILES_LIMIT | An integer indicating the maximum request body size ModSecurity will accept for buffering (Default: `131072`). See [SecRequestBodyNoFilesLimit](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secrequestbodynofileslimit) for more information. | +| MODSEC_RESP_BODY_ACCESS | A string value allowing ModSecurity to access response bodies (Default: `On`). Allowed values: `On`, `Off`. See [SecResponseBodyAccess](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secresponsebodyaccess) for more information. | +| MODSEC_RESP_BODY_LIMIT | An integer value indicating the maximum response body size accepted for buffering (Default: `1048576`) | +| MODSEC_RESP_BODY_LIMIT_ACTION | A string value for the action when `SecResponseBodyLimit` is reached (Default: `ProcessPartial`). Accepted values: `Reject`, `ProcessPartial`. See [SecResponseBodyLimitAction](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#secresponsebodylimitaction) for additional information. | +| MODSEC_RESP_BODY_MIMETYPE | A string with the list of mime types that will be analyzed in the response (Default: `'text/plain text/html text/xml'`). You might consider adding `application/json` documented [here](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-\(v2.x\)#secresponsebodymimetype). | +| MODSEC_RULE_ENGINE | A string value enabling ModSecurity itself (Default: `On`). Accepted values: `On`, `Off`, `DetectionOnly`. See [SecRuleEngine](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secruleengine) for additional information. | +| MODSEC_SERVER_SIGNATURE | Sets the directive [SecServerSignature](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#secserversignature) and instructs ModSecurity to change the data presented in the "Server:" response header token when Apache `ServerTokens` directive is set to `Full`. Also see Apache `SERVER_TOKENS`. Only supported in ModSecurity 2.x, will have not effect on 3.x. (Default: `Apache`). | +| MODSEC_STATUS_ENGINE | A string used to configure the status engine, which sends statistical information (Default: `Off`). Accepted values: `On`, `Off`. See [SecStatusEngine](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#SecStatusEngine) for additional information. | +| MODSEC_TAG | A string indicating the default tag action, which will be inherited by the rules in the same configuration context (Default: `modsecurity`) | +| MODSEC_TMP_DIR | A string indicating the path where temporary files will be created (Default: `/tmp/modsecurity/tmp`) | +| MODSEC_TMP_SAVE_UPLOADED_FILES | A string indicating if temporary uploaded files are saved (Default: `On`) (only relevant in Apache - ModSecurity v2) | +| MODSEC_UPLOAD_DIR | A string indicating the path where intercepted files will be stored (Default: `/tmp/modsecurity/upload`) | | MODSEC_DEFAULT_PHASE1_ACTION | ModSecurity string with the contents for the default action in phase 1 (Default: `'phase:1,log,auditlog,pass,tag:\'\${MODSEC_TAG}\''`) | | MODSEC_DEFAULT_PHASE2_ACTION | ModSecurity string with the contents for the default action in phase 2 (Default: `'phase:2,log,auditlog,pass,tag:\'\${MODSEC_TAG}\''`) | -### Overridden - -| Name | Description| -| -- | -- | -| BACKEND | Backend address (and optional port) of the backend server. (Default: the container's default router, port 81) (Examples: 192.0.2.2, 192.0.2.2:80, ) | - ### CRS specific -| Name | Description| -| -- | -- | -| MANUAL_MODE | A bool indicating that you are providing your own `crs-setup.conf` file mounted as volume. (Default: `0`). ⚠️ None of the following variables are used if you set it to `1`. | -| CRS_DISABLE_PLUGINS | A bool indicating whether plugins will be **disabled** (Only from v4 and up. Default: `0`) | -| PARANOIA | An int indicating the paranoia level (Default: `1`) | -| BLOCKING_PARANOIA | (:new: Replaces `PARANOIA` in CRSv4) An int indicating the paranoia level (Default: `1`) | -| EXECUTING_PARANOIA | An int indicating the executing_paranoia_level (Default: `PARANOIA`) | -| DETECTION_PARANOIA | (:new: Replaces `EXECUTING_PARANOIA` in CRSv4) An int indicating the detection_paranoia_level (Default: `BLOCKING_PARANOIA`) | -| ENFORCE_BODYPROC_URLENCODED | A bool indicating the enforce_bodyproc_urlencoded (Default: `0`) | -| VALIDATE_UTF8_ENCODING | A bool indicating the crs_validate_utf8_encoding (Default: `0`) | -| ANOMALY_INBOUND | An int indicating the inbound_anomaly_score_threshold (Default: `5`) | -| ANOMALY_OUTBOUND | An int indicating the outbound_anomaly_score_threshold (Default: `4`) | -| ALLOWED_METHODS | Allowed_methods (Default: `GET HEAD POST OPTIONS`) | -| ALLOWED_REQUEST_CONTENT_TYPE | Allowed_request_content_type (Default: `\|application/x-www-form-urlencoded\| \|multipart/form-data\| \|multipart/related\| \|text/xml\| \|application/xml\| \|application/soap+xml\| \|application/json\| \|application/cloudevents+json\| \|application/cloudevents-batch+json\|`) | -| ALLOWED_REQUEST_CONTENT_TYPE_CHARSET | Allowed_request_content_type_charset (Default: `utf-8\|iso-8859-1\|iso-8859-15\|windows-1252`) | -| ALLOWED_HTTP_VERSIONS | Allowed_http_versions (Default: `HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0`) | -| RESTRICTED_EXTENSIONS | Restricted_extensions (Default: `.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .rdb/ .resources/ .resx/ .sql/ .swp/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/`) | -| RESTRICTED_HEADERS | Restricted_headers (Default: `/accept-charset/ /content-encoding/ /proxy/ /lock-token/ /content-range/ /if/`) | -| STATIC_EXTENSIONS | Static_extensions (Default: `/.jpg/ /.jpeg/ /.png/ /.gif/ /.js/ /.css/ /.ico/ /.svg/ /.webp/`) | -| MAX_NUM_ARGS | An int indicating the max_num_args (Default: `unlimited`) | -| ARG_NAME_LENGTH | An int indicating the arg_name_length (Default: `unlimited`) | -| ARG_LENGTH | An int indicating the arg_length (Default: `unlimited`) | -| TOTAL_ARG_LENGTH | An int indicating the total_arg_length (Default: `unlimited`) | -| MAX_FILE_SIZE | An int indicating the max_file_size (Default: `unlimited`) | -| COMBINED_FILE_SIZES | An int indicating the combined_file_sizes (Default: `unlimited`) | -| CRS_ENABLE_TEST_MARKER | A bool indicating whether to write test markers to the log file (Used for running the CRS test suite. Default: `0`) | +| Name | Description| +| -------- | ------------------------------------------------------------------- | +| MANUAL_MODE | A boolean indicating that you are providing your own `crs-setup.conf` file mounted as volume. (Default: `0`). ⚠️ None of the following variables are used if you set it to `1`. | +| CRS_DISABLE_PLUGINS | A boolean indicating whether plugins will be **disabled** (Only from v4 and up. Default: `0`) | +| PARANOIA | An integer indicating the paranoia level (Default: `1`) | +| BLOCKING_PARANOIA | (:new: Replaces `PARANOIA` in CRSv4) An integer indicating the paranoia level (Default: `1`) | +| EXECUTING_PARANOIA | An integer indicating the executing_paranoia_level (Default: `PARANOIA`) | +| DETECTION_PARANOIA | (:new: Replaces `EXECUTING_PARANOIA` in CRSv4) An integer indicating the detection_paranoia_level (Default: `BLOCKING_PARANOIA`) | +| ENFORCE_BODYPROC_URLENCODED | A boolean indicating the enforce_bodyproc_urlencoded (Default: `0`) | +| VALIDATE_UTF8_ENCODING | A boolean indicating the crs_validate_utf8_encoding (Default: `0`) | +| ANOMALY_INBOUND | An integer indicating the inbound_anomaly_score_threshold (Default: `5`) | +| ANOMALY_OUTBOUND | An integer indicating the outbound_anomaly_score_threshold (Default: `4`) | +| ALLOWED_METHODS | A string indicating the allowed_methods (Default: `GET HEAD POST OPTIONS`) | +| ALLOWED_REQUEST_CONTENT_TYPE | A string indicating the allowed_request_content_type (Default: `\|application/x-www-form-urlencoded\| \|multipart/form-data\| \|multipart/related\| \|text/xml\| \|application/xml\| \|application/soap+xml\| \|application/json\| \|application/cloudevents+json\| \|application/cloudevents-batch+json\|`) | +| ALLOWED_REQUEST_CONTENT_TYPE_CHARSET | A string indicating the allowed_request_content_type_charset (Default: `utf-8\|iso-8859-1\|iso-8859-15\|windows-1252`) | +| ALLOWED_HTTP_VERSIONS | A string indicating the allowed_http_versions (Default: `HTTP/1.0 HTTP/1.1 HTTP/2 HTTP/2.0`) | +| RESTRICTED_EXTENSIONS | A string indicating the restricted_extensions (Default: `.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .rdb/ .resources/ .resx/ .sql/ .swp/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/`) | +| RESTRICTED_HEADERS | A string indicating the restricted_headers (Default: `/accept-charset/ /content-encoding/ /proxy/ /lock-token/ /content-range/ /if/`) | +| STATIC_EXTENSIONS | A string indicating the static_extensions (Default: `/.jpg/ /.jpeg/ /.png/ /.gif/ /.js/ /.css/ /.ico/ /.svg/ /.webp/`) | +| MAX_NUM_ARGS | An integer indicating the max_num_args (Default: `unlimited`) | +| ARG_NAME_LENGTH | An integer indicating the arg_name_length (Default: `unlimited`) | +| ARG_LENGTH | An integer indicating the arg_length (Default: `unlimited`) | +| TOTAL_ARG_LENGTH | An integer indicating the total_arg_length (Default: `unlimited`) | +| MAX_FILE_SIZE | An integer indicating the max_file_size (Default: `unlimited`) | +| COMBINED_FILE_SIZES | An integer indicating the combined_file_sizes (Default: `unlimited`) | +| CRS_ENABLE_TEST_MARKER | A boolean indicating whether to write test markers to the log file (Used for running the CRS test suite. Default: `0`) | diff --git a/README.md b/README.md index 98b21ccb..13a354f9 100644 --- a/README.md +++ b/README.md @@ -145,37 +145,6 @@ An example can be seen in the [docker-compose](https://github.com/coreruleset/mo > 💬 What happens if I want to make changes in a different file, like `/etc/nginx/conf.d/default.conf`? > You mount your local file, e.g. `nginx/default.conf` as the new template: `/etc/nginx/templates/conf.d/default.conf.template`. You can do this similarly with other files. Files in the templates directory will be copied and subdirectories will be preserved. -### TLS/HTTPS - -TLS is configured by default on port 443. Note: The default configuration generates a self signed certificate on first run. To use your own certificates (recommended) `COPY` or mount (`-v`) your `server.crt` and `server.key` into `/usr/local/apache2/conf/` or `/etc/nginx/conf/`. Remember to publish the HTTPS port when running the image. - -```bash -docker build -t my-modsec . -docker run -p 8443:443 my-modsec -``` - -We use sane intermediate defaults taken from the [Mozilla SSL config tool](https://ssl-config.mozilla.org/). Please check it and choose the best that match your needs. - -You can use variables on nginx and apache to always redirect from http to https if needed (see APACHE_ALWAYS_TLS_REDIRECT and NGINX_ALWAYS_TLS_REDIRECT below). - -### Proxying - -ModSecurity is often used as a reverse proxy. This allows one to use ModSecurity without modifying the webserver hosting the underlying application (and also protect web servers that modsecurity cannot currently embedd into). The proxy is set by default to true and the location is defined by BACKEND environment variable. The SSL is enabled by default. - -```bash -docker build -t my-modsec . -f -docker run -p 8080:80 -e PROXY_SSL=on -e BACKEND=http://example.com my-modsec -``` - -### ServerName - -It is often convenient to set your servername. To do this simply use the `SERVER_NAME` environment variable passed to docker run. By default the servername provided is `localhost`. - -```bash -docker build -t modsec . -docker run -p 8080:80 -e SERVER_NAME=myhost my-modsec -``` - ### Apache ENV Variables | Name | Description| @@ -197,11 +166,14 @@ docker run -p 8080:80 -e SERVER_NAME=myhost my-modsec | PORT | An integer value indicating the port where the webserver is listening to (Default: `80`) | | PROXY_ERROR_OVERRIDE | A string indicating that errors from the backend services should be overridden by this proxy server (see [ProxyErrorOverride](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxyerroroverride) directive). (Allowed values: `on`, `off`. Default: `on`) | | PROXY_PRESERVE_HOST | A string indicating the use of incoming Host HTTP request header for proxy request (Default: `on`) | -| PROXY_SSL_CERT_KEY | A string indicating the path to the server PEM-encoded private key file (Default: `/usr/local/apache2/conf/server.key`) | -| PROXY_SSL_CERT | A string indicating the path to the server PEM-encoded X.509 certificate data file or token identifier (Default: `/usr/local/apache2/conf/server.crt`) | +| PROXY_SSL | A string indicating SSL Proxy Engine Operation Switch (Default: `on`) | +| PROXY_SSL_CA_CERT | A string indicating the path to the PEM-encoded list of accepted CA certificates for the proxied server (Default: `/etc/ssl/certs/ca-certificates.ca`) | +| PROXY_SSL_CERT | A string indicating the path to the PEM-encoded X.509 certificate data file or token identifier of the proxied server (Default: `/usr/local/apache2/conf/proxy.crt`) | +| PROXY_SSL_CERT_KEY | A string indicating the path to the PEM-encoded private key file of the proxied server (Default: `/usr/local/apache2/conf/proxy.key`) | | PROXY_SSL_CHECK_PEER_NAME | A string indicating if the host name checking for remote server certificates is to be enabled (Default: `on`) | +| PROXY_SSL_CIPHER_SUITE | A string indicating the cipher suite to connect to the backend via TLS. (Default `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | +| PROXY_SSL_PROTOCOL | A string for configuring the [proxy client SSL/TLS protocol versions](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslproxyprotocol) (Default: `"all -SSLv3 -TLSv1 -TLSv1.1"`) | | PROXY_SSL_VERIFY | A string value indicating the type of remote server Certificate verification (Default: `none`) | -| PROXY_SSL | A string indicating SSL Proxy Engine Operation Switch (Default: `off`) | | PROXY_TIMEOUT | Number of seconds for proxied requests to time out (Default: `60`) | | REMOTEIP_INT_PROXY | A string indicating the client intranet IP addresses trusted to present the RemoteIPHeader value (Default: `10.1.0.0/16`) | | REQ_HEADER_FORWARDED_PROTO | A string indicating the transfer protocol of the initial request (Default: `https`) | @@ -209,13 +181,13 @@ docker run -p 8080:80 -e SERVER_NAME=myhost my-modsec | SERVER_NAME | A string value indicating the server name (Default: `localhost`) | | SERVER_SIGNATURE | A string value configuring the footer on server-generated documents (Allowed values: `On`, `Off`, `EMail`. Default: `Off`) | | SERVER_TOKENS | Option defining the server information presented to clients in the `Server` HTTP response header. Also see `MODSEC_SERVER_SIGNATURE`. (Allowed values: `Full`, `Prod[uctOnly]`, `Major`, `Minor`, `Min[imal]`, `OS`. Default: `Full`). | +| SSL_CERT | A string indicating the path to the PEM-encoded X.509 certificate data file or token identifier of the server (Default: `/usr/local/apache2/conf/proxy.crt`) | +| SSL_CERT_KEY | A string indicating the path to the PEM-encoded private key file of the server (Default: `/usr/local/apache2/conf/proxy.key`) | | SSL_CIPHER_SUITE | A string indicating the cipher suite to use. Uses OpenSSL [list of cipher suites](https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_ciphersuites.html) (Default: `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | | SSL_ENGINE | A string indicating the SSL Engine Operation Switch (Default: `on`) | | SSL_HONOR_CIPHER_ORDER | A string indicating if the server should [honor the cipher list provided by the client](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslhonorcipherorder) (Allowed values: `on`, `off`. Default: `off`) | | SSL_PORT | Port number where the SSL enabled webserver is listening (Default: `443`) | | SSL_PROTOCOL | A string for configuring the [usable SSL/TLS protocol versions](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslprotocol) (Default: `"all -SSLv3 -TLSv1 -TLSv1.1"`) | -| SSL_PROXY_PROTOCOL | A string for configuring the [proxy client SSL/TLS protocol versions](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslproxyprotocol) (Default: `"all -SSLv3 -TLSv1 -TLSv1.1"`) | -| SSL_PROXY_CIPHER_SUITE | A string indicating the cipher suite to connect to the backend via TLS. (Default `"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"` | | SSL_SESSION_TICKETS | A string to enable or disable the use of [TLS session tickets](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslsessiontickets) (RFC 5077). (Default: `off`) | | SSL_USE_STAPLING | A string indicating if [OSCP Stapling](https://httpd.apache.org/docs/2.4/mod/mod_ssl.html#sslusestapling) should be used (Allowed values: `on`, `off`. Default: `on`) | | TIMEOUT | Number of seconds before receiving and sending timeout (Default: `60`) | @@ -241,17 +213,26 @@ Note: Apache access and metric logs can be disabled by exporting the `nologging= | REAL_IP_HEADER | Name of the header containing the real IP value(s) (Default: `X-REAL-IP`). See [real_ip_header](http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_header) | | REAL_IP_PROXY_HEADER | Name of the header containing `$remote_addr` to be passed to proxy (Default: `X-REAL-IP`). See [proxy_set_header](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header) | | REAL_IP_RECURSIVE | A string value indicating whether to use recursive reaplacement on addresses in `REAL_IP_HEADER` (Allowed values: `on`, `off`. Default: `on`). See [real_ip_recursive](http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive) | +| PROXY_SSL | A string indicating SSL Proxy Engine Operation Switch (Default: `on`) | | PROXY_SSL_CERT | A string value indicating the path to the server PEM-encoded X.509 certificate data file or token value identifier (Default: `/etc/nginx/conf/server.crt`) | | PROXY_SSL_CERT_KEY | A string value indicating the path to the server PEM-encoded private key file (Default: `/etc/nginx/conf/server.key`) | | PROXY_SSL_CIPHERS | A String value indicating the enabled ciphers. The ciphers are specified in the format understood by the OpenSSL library. (Default: `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;`| -| PROXY_SSL_DH_BITS | A numeric value indicating the size (in bits) to use for the generated DH-params file (Default 2048) | -| PROXY_SSL_OCSP_STAPLING | A string value indicating if ssl_stapling and ssl_stapling_verify should be enabled (Allowed values: `on`, `off`. Default: `off`) | -| PROXY_SSL_PREFER_CIPHERS | A string value indicating if the server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols (Allowed values: `on`, `off`. Default: `off`)| | PROXY_SSL_PROTOCOLS | A string value indicating the ssl protocols to enable (default: `TTLSv1.2 TLSv1.3`)| | PROXY_SSL_VERIFY | A string value indicating if the client certificates should be verified (Allowed values: `on`, `off`. Default: `off`) | +| PROXY_SSL_VERIFY_DEPTH | An integer value indicating the verification depth for the client certificate chain (Default: `1`) | | PROXY_TIMEOUT | Number of seconds for proxied requests to time out connections (Default: `60s`) | +| SERVER_NAME | A string value indicating the server name (Default: `localhost`) | | SERVER_TOKENS | A boolean value for enabling / disabling emission of server identifying information in the `Server` HTTP response header and on error pages. (Allowed values: `on`, `off`, `build`. Default: `off`). | +| SSL_CERT | A string value indicating the path to the server PEM-encoded X.509 certificate data file or token value identifier (Default: `/etc/nginx/conf/server.crt`) | +| SSL_CERT_KEY | A string value indicating the path to the server PEM-encoded private key file (Default: `/etc/nginx/conf/server.key`) | +| SSL_CIPHERS | A String value indicating the enabled ciphers. The ciphers are specified in the format understood by the OpenSSL library. (Default: `ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;`| +| SSL_DH_BITS | A numeric value indicating the size (in bits) to use for the generated DH-params file (Default 2048) | +| SSL_OCSP_STAPLING | A string value indicating if ssl_stapling and ssl_stapling_verify should be enabled (Allowed values: `on`, `off`. Default: `off`) | | SSL_PORT | Port number where the SSL enabled webserver is listening (Default: `443`) | +| SSL_PREFER_CIPHERS | A string value indicating if the server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols (Allowed values: `on`, `off`. Default: `off`)| +| SSL_PROTOCOLS | A string value indicating the ssl protocols to enable (default: `TTLSv1.2 TLSv1.3`)| +| SSL_VERIFY | A string value indicating if the client certificates should be verified (Allowed values: `on`, `off`. Default: `off`) | +| SSL_VERIFY_DEPTH | An integer value indicating the verification depth for the client certificate chain (Default: `1`) | | TIMEOUT | Number of seconds for a keep-alive client connection to stay open on the server side (Default: `60s`) | | WORKER_CONNECTIONS | Maximum number of simultaneous connections that can be opened by a worker process (Default: `1024`) | @@ -296,12 +277,6 @@ All these variables impact in configuration directives in the modsecurity engine | MODSEC_DEFAULT_PHASE1_ACTION | ModSecurity string with the contents for the default action in phase 1 (Default: `'phase:1,log,auditlog,pass,tag:\'\${MODSEC_TAG}\''`) | | MODSEC_DEFAULT_PHASE2_ACTION | ModSecurity string with the contents for the default action in phase 2 (Default: `'phase:2,log,auditlog,pass,tag:\'\${MODSEC_TAG}\''`) | -### Overridden - -| Name | Description| -| -------- | ------------------------------------------------------------------- | -| BACKEND | The backend address (and optional port) of the backend server. (Default: the container's default router, port 81) (Examples: 192.0.2.2, 192.0.2.2:80, ) | - ### CRS specific | Name | Description| @@ -331,14 +306,53 @@ All these variables impact in configuration directives in the modsecurity engine | COMBINED_FILE_SIZES | An integer indicating the combined_file_sizes (Default: `unlimited`) | | CRS_ENABLE_TEST_MARKER | A boolean indicating whether to write test markers to the log file (Used for running the CRS test suite. Default: `0`) | -## Notes regarding reverse proxy +## TLS/HTTPS + +> [!IMPORTANT] +> The default configuration generates a self signed certificate on first run. To use your own certificates (recommended) `COPY` or mount (`-v`) your `server.crt` and `server.key` into `/usr/local/apache2/conf/` or `/etc/nginx/conf/`. Remember to publish the HTTPS port when running the image. +> +> ```bash +> docker build -t my-modsec . +> docker run -p 8443:443 my-modsec +> ``` + +TLS is configured on port `443` and enabled by default. + +We use sane intermediate defaults taken from the [Mozilla SSL config tool](https://ssl-config.mozilla.org/). Please review the defaults and choose the ones that best match your needs. + +You can set the `*_ALWAYS_TLS_REDIRECT` environment variables to always redirect from `http` to `https`. + +## Proxy Configuration + +The owasp/modsecurity-crs container images in their default configuration (i.e., without manual changes to / overrides of configuration files) act as reverse proxies and require a running backend at the address specified through the `BACKEND` environment variable. + +> [!IMPORTANT] +> Make sure to set the `BACKEND` variable to an address where a web server is listening. Otherwise nothing useful will happen when you send requests to the owasp/modsecurity-crs container (at least not with the default configurational). + +ModSecurity is often used in a reverse proxy setup with the following porperties: +- reverse proxy acts as public end point +- reverse proxy performs TLS termination (necessary for ModSecurity to inspect content) +- ModSecurity runs on the reverse proxy to filter traffic +- only benign traffic is passed to the backend -In order to more easily test drive the CRS ruleset, we include support for an technique called [Reverse Proxy](https://en.wikipedia.org/wiki/Reverse_proxy). Using this technique, you keep your pre-existing web server online at a non-standard host and port, and then configure the CRS container to accept public traffic. The CRS container then proxies the traffic to your pre-existing webserver. This way, you can test out CRS with any web server. Some notes: +This allows one to use ModSecurity without modifying the webserver hosting the underlying application and also protects web servers that ModSecurity cannot currently be embedd into. -* Proxy is not enabled by default. You'll need to pass the `-e PROXY=1` environment variable to enable it. -* You'll want to configure your typical webserver to listen on your docker interface only (i.e. 172.17.0.1:81) so that public traffic doesn't reach it. -* Do not use 127.0.0.1 as an UPSTREAM address. The loopback interface inside the docker container is not the same interface as the one on docker host. -* Note that traffic coming through this proxy will look like it's coming from the wrong address. You may want to configure your pre-existing webserver to use the `X-Forwarded-For` HTTP header to populate the remote address field for traffic from the proxy. +Tips: +* the application web server (the one receiving traffic from the reverse proxy) should not listen on a public interface. Only the reverse proxy should be exposed to the public. With Docker, this could meain setting up a network for both containers and only exposing the reverse proxy with `-p 8080:80`, for example. `docker compose` takes care of this automatically. See the `docker-compose.yaml` for an example setup. + +```bash +docker build -t my-modsec . -f +docker run -p 8080:80 -e BACKEND=http://example.com my-modsec +``` + +## ServerName + +It is often convenient to set your server name (set to `localhost` by defualt). To do this simply use the `SERVER_NAME` environment variable. + +```bash +docker build -t modsec . +docker run -p 8080:80 -e SERVER_NAME=myhost my-modsec +``` ## ModSecurity CRS Tuning @@ -394,7 +408,6 @@ docker run -dti -p 80:80 --rm \ -e TOTAL_ARG_LENGTH=6400 \ -e MAX_FILE_SIZE=100000 \ -e COMBINED_FILE_SIZES=1000000 \ - -e PROXY=1 \ -e TIMEOUT=60 \ -e LOGLEVEL=warn \ -e ERRORLOG='/proc/self/fd/2' \ diff --git a/apache/Dockerfile b/apache/Dockerfile index fffc66cd..963c1243 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -64,19 +64,19 @@ ARG LUA_VERSION="n/a" LABEL maintainer="Felipe Zipitria " ENV APACHE_ALWAYS_TLS_REDIRECT=off \ + APACHE_LOGFORMAT='"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""' \ + APACHE_ERRORLOG_FORMAT='"[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i"' \ + APACHE_METRICS_LOGFORMAT='"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""' \ ACCESSLOG=/var/log/apache2/access.log \ BACKEND=http://localhost:80 \ BACKEND_WS=ws://localhost:8080 \ ERRORLOG='/proc/self/fd/2' \ - APACHE_LOGFORMAT='"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""' \ - APACHE_ERRORLOG_FORMAT='"[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i"' \ - APACHE_METRICS_LOGFORMAT='"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""' \ H2_PROTOCOLS='h2 http/1.1' \ LOGLEVEL=warn \ METRICS_ALLOW_FROM='127.0.0.0/255.0.0.0 ::1/128' \ METRICS_DENY_FROM='All' \ - METRICSLOG='/dev/null' \ MUTEX='default' \ + METRICSLOG='/dev/null' \ MODSEC_AUDIT_ENGINE="RelevantOnly" \ MODSEC_AUDIT_LOG_FORMAT=JSON \ MODSEC_AUDIT_LOG_TYPE=Serial \ @@ -110,12 +110,14 @@ ENV APACHE_ALWAYS_TLS_REDIRECT=off \ PORT=80 \ PROXY_ERROR_OVERRIDE=on \ PROXY_PRESERVE_HOST=on \ + PROXY_SSL=on \ PROXY_SSL_CA_CERT=/etc/ssl/certs/ca-certificates.crt \ - PROXY_SSL_CERT_KEY=/usr/local/apache2/conf/server.key \ - PROXY_SSL_CERT=/usr/local/apache2/conf/server.crt \ + PROXY_SSL_CERT=/usr/local/apache2/conf/proxy.crt \ + PROXY_SSL_CERT_KEY=/usr/local/apache2/conf/proxy.key \ PROXY_SSL_CHECK_PEER_NAME=off \ + PROXY_SSL_CIPHER_SUITE="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ + PROXY_SSL_PROTOCOL="all -SSLv3 -TLSv1 -TLSv1.1" \ PROXY_SSL_VERIFY=none \ - PROXY_SSL=on \ PROXY_TIMEOUT=60 \ REMOTEIP_INT_PROXY='10.1.0.0/16' \ REQ_HEADER_FORWARDED_PROTO='https' \ @@ -123,13 +125,13 @@ ENV APACHE_ALWAYS_TLS_REDIRECT=off \ SERVER_NAME=localhost \ SERVER_SIGNATURE=Off \ SERVER_TOKENS=Full \ + SSL_CERT=/usr/local/apache2/conf/server.crt \ + SSL_CERT_KEY=/usr/local/apache2/conf/server.key \ SSL_CIPHER_SUITE="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ SSL_ENGINE=on \ SSL_HONOR_CIPHER_ORDER=off \ SSL_PORT=443 \ SSL_PROTOCOL="all -SSLv3 -TLSv1 -TLSv1.1" \ - SSL_PROXY_PROTOCOL="all -SSLv3 -TLSv1 -TLSv1.1" \ - SSL_PROXY_CIPHER_SUITE="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ SSL_SESSION_TICKETS=off \ SSL_USE_STAPLING=On \ TIMEOUT=60 \ diff --git a/apache/Dockerfile-alpine b/apache/Dockerfile-alpine index c2f629a4..9a68b494 100644 --- a/apache/Dockerfile-alpine +++ b/apache/Dockerfile-alpine @@ -120,12 +120,14 @@ ENV APACHE_ALWAYS_TLS_REDIRECT=off \ PORT=80 \ PROXY_ERROR_OVERRIDE=on \ PROXY_PRESERVE_HOST=on \ + PROXY_SSL=on \ PROXY_SSL_CA_CERT=/etc/ssl/certs/ca-certificates.crt \ - PROXY_SSL_CERT_KEY=/usr/local/apache2/conf/server.key \ - PROXY_SSL_CERT=/usr/local/apache2/conf/server.crt \ + PROXY_SSL_CERT=/usr/local/apache2/conf/proxy.crt \ + PROXY_SSL_CERT_KEY=/usr/local/apache2/conf/proxy.key \ PROXY_SSL_CHECK_PEER_NAME=off \ + PROXY_SSL_CIPHER_SUITE="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ + PROXY_SSL_PROTOCOL="all -SSLv3 -TLSv1 -TLSv1.1" \ PROXY_SSL_VERIFY=none \ - PROXY_SSL=on \ PROXY_TIMEOUT=60 \ REMOTEIP_INT_PROXY='10.1.0.0/16' \ REQ_HEADER_FORWARDED_PROTO='https' \ @@ -133,13 +135,13 @@ ENV APACHE_ALWAYS_TLS_REDIRECT=off \ SERVER_NAME=localhost \ SERVER_SIGNATURE=Off \ SERVER_TOKENS=Full \ + SSL_CERT=/usr/local/apache2/conf/server.crt \ + SSL_CERT_KEY=/usr/local/apache2/conf/server.key \ SSL_CIPHER_SUITE="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ SSL_ENGINE=on \ SSL_HONOR_CIPHER_ORDER=off \ SSL_PORT=443 \ SSL_PROTOCOL="all -SSLv3 -TLSv1 -TLSv1.1" \ - SSL_PROXY_PROTOCOL="all -SSLv3 -TLSv1 -TLSv1.1" \ - SSL_PROXY_CIPHER_SUITE="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ SSL_SESSION_TICKETS=off \ SSL_USE_STAPLING=On \ TIMEOUT=60 \ diff --git a/apache/conf/extra/httpd-ssl.conf b/apache/conf/extra/httpd-ssl.conf index 182610a6..a436e21d 100644 --- a/apache/conf/extra/httpd-ssl.conf +++ b/apache/conf/extra/httpd-ssl.conf @@ -1,7 +1,7 @@ Listen ${SSL_PORT} -SSLProxyProtocol ${SSL_PROXY_PROTOCOL} -SSLProxyCipherSuite ${SSL_PROXY_CIPHER_SUITE} +SSLProxyProtocol ${PROXY_SSL_PROTOCOL} +SSLProxyCipherSuite ${PROXY_SSL_CIPHER_SUITE} SSLPassPhraseDialog builtin diff --git a/apache/conf/extra/httpd-vhosts.conf b/apache/conf/extra/httpd-vhosts.conf index e0984a38..b943e05d 100644 --- a/apache/conf/extra/httpd-vhosts.conf +++ b/apache/conf/extra/httpd-vhosts.conf @@ -41,6 +41,6 @@ UseCanonicalName on Protocols ${H2_PROTOCOLS} SSLEngine ${SSL_ENGINE} - SSLCertificateFile ${PROXY_SSL_CERT} - SSLCertificateKeyFile ${PROXY_SSL_CERT_KEY} + SSLCertificateFile ${SSL_CERT} + SSLCertificateKeyFile ${SSL_CERT_KEY} diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 6dd44990..0828effa 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -144,18 +144,26 @@ ENV ACCESSLOG=/var/log/nginx/access.log \ REAL_IP_HEADER="X-REAL-IP" \ REAL_IP_PROXY_HEADER="X-REAL-IP" \ REAL_IP_RECURSIVE="on" \ - PROXY_TIMEOUT=60s \ - PROXY_SSL_CERT=/etc/nginx/conf/server.crt \ - PROXY_SSL_CERT_KEY=/etc/nginx/conf/server.key \ - PROXY_SSL_DH_BITS=2048 \ - PROXY_SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ + PROXY_SSL=off \ + PROXY_SSL_CERT=/etc/nginx/conf/proxy.crt \ + PROXY_SSL_CERT_KEY=/etc/nginx/conf/proxy.key \ PROXY_SSL_CIPHERS="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ - PROXY_SSL_PREFER_CIPHERS=off \ + PROXY_SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ PROXY_SSL_VERIFY=off \ - PROXY_SSL_OCSP_STAPLING=off \ + PROXY_SSL_VERIFY_DEPTH=1 \ + PROXY_TIMEOUT=60s \ SERVER_NAME=localhost \ SERVER_TOKENS=off \ + SSL_CERT=/etc/nginx/conf/server.crt \ + SSL_CERT_KEY=/etc/nginx/conf/server.key \ + SSL_CIPHERS="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ + SSL_DH_BITS=2048 \ + SSL_OCSP_STAPLING=off \ SSL_PORT=443 \ + SSL_PREFER_CIPHERS=off \ + SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ + SSL_VERIFY=off \ + SSL_VERIFY_DEPTH=1 \ TIMEOUT=60s \ WORKER_CONNECTIONS=1024 \ LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib \ diff --git a/nginx/Dockerfile-alpine b/nginx/Dockerfile-alpine index c388b831..562ff9bb 100644 --- a/nginx/Dockerfile-alpine +++ b/nginx/Dockerfile-alpine @@ -139,18 +139,26 @@ ENV ACCESSLOG=/var/log/nginx/access.log \ REAL_IP_HEADER="X-REAL-IP" \ REAL_IP_PROXY_HEADER="X-REAL-IP" \ REAL_IP_RECURSIVE="on" \ - PROXY_TIMEOUT=60s \ - PROXY_SSL_CERT=/etc/nginx/conf/server.crt \ - PROXY_SSL_CERT_KEY=/etc/nginx/conf/server.key \ - PROXY_SSL_DH_BITS=2048 \ - PROXY_SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ + PROXY_SSL=off \ + PROXY_SSL_CERT=/etc/nginx/conf/proxy.crt \ + PROXY_SSL_CERT_KEY=/etc/nginx/conf/proxy.key \ PROXY_SSL_CIPHERS="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ - PROXY_SSL_PREFER_CIPHERS=off \ + PROXY_SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ PROXY_SSL_VERIFY=off \ - PROXY_SSL_OCSP_STAPLING=off \ + PROXY_SSL_VERIFY_DEPTH=1 \ + PROXY_TIMEOUT=60s \ SERVER_NAME=localhost \ SERVER_TOKENS=off \ + SSL_CERT=/etc/nginx/conf/server.crt \ + SSL_CERT_KEY=/etc/nginx/conf/server.key \ + SSL_CIPHERS="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ + SSL_DH_BITS=2048 \ + SSL_OCSP_STAPLING=off \ SSL_PORT=443 \ + SSL_PREFER_CIPHERS=off \ + SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ + SSL_VERIFY_DEPTH=1 \ + SSL_VERIFY=off \ TIMEOUT=60s \ WORKER_CONNECTIONS=1024 \ LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib \ diff --git a/nginx/docker-entrypoint.d/91-update-resolver.sh b/nginx/docker-entrypoint.d/91-update-resolver.sh index 7846c1d0..2afca720 100755 --- a/nginx/docker-entrypoint.d/91-update-resolver.sh +++ b/nginx/docker-entrypoint.d/91-update-resolver.sh @@ -4,7 +4,6 @@ set -eu LC_ALL=C -ME=$( basename "$0" ) PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DNS_SERVER="${DNS_SERVER:-$(grep -i '^nameserver' /etc/resolv.conf | head -n1 | cut -d ' ' -f2)}" diff --git a/nginx/docker-entrypoint.d/92-update-real_ip.sh b/nginx/docker-entrypoint.d/92-update-real_ip.sh index fae02bfe..c4a7da95 100755 --- a/nginx/docker-entrypoint.d/92-update-real_ip.sh +++ b/nginx/docker-entrypoint.d/92-update-real_ip.sh @@ -4,7 +4,6 @@ set -eu LC_ALL=C -ME=$( basename "$0" ) PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # split comma separated IP addresses into multiple `set_real_ip xxx;` lines diff --git a/nginx/docker-entrypoint.d/93-update-proxy-ssl-config.sh b/nginx/docker-entrypoint.d/93-update-proxy-ssl-config.sh new file mode 100755 index 00000000..aca86ee3 --- /dev/null +++ b/nginx/docker-entrypoint.d/93-update-proxy-ssl-config.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# vim:sw=2:ts=2:sts=2:et + +set -eu + +LC_ALL=C +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +PROXY_SSL_CONFIG="" +if [ "${PROXY_SSL}" = "on" ]; then + PROXY_SSL_CONFIG="include includes/proxy_backend_ssl.conf;" +fi + +sed -i.bak -r 's#PROXY_SSL_CONFIG#'"${PROXY_SSL_CONFIG}"'#' /etc/nginx/conf.d/default.conf diff --git a/nginx/templates/conf.d/default.conf.template b/nginx/templates/conf.d/default.conf.template index c934208f..56e050d4 100644 --- a/nginx/templates/conf.d/default.conf.template +++ b/nginx/templates/conf.d/default.conf.template @@ -14,6 +14,8 @@ server { set $upstream ${BACKEND}; set $always_redirect ${NGINX_ALWAYS_TLS_REDIRECT}; + PROXY_SSL_CONFIG + location / { client_max_body_size 0; @@ -37,22 +39,25 @@ server { server_name ${SERVER_NAME}; set $upstream ${BACKEND}; - ssl_certificate ${PROXY_SSL_CERT}; - ssl_certificate_key ${PROXY_SSL_CERT_KEY}; + ssl_certificate ${SSL_CERT}; + ssl_certificate_key ${SSL_CERT_KEY}; ssl_session_timeout 1d; ssl_session_cache shared:MozSSL:10m; ssl_session_tickets off; - ssl_dhparam /etc/ssl/certs/dhparam-${PROXY_SSL_DH_BITS}.pem; + ssl_dhparam /etc/ssl/certs/dhparam-${SSL_DH_BITS}.pem; + + ssl_protocols ${SSL_PROTOCOLS}; + ssl_ciphers ${SSL_CIPHERS}; + ssl_prefer_server_ciphers ${SSL_PREFER_CIPHERS}; - ssl_protocols ${PROXY_SSL_PROTOCOLS}; - ssl_ciphers ${PROXY_SSL_CIPHERS}; - ssl_prefer_server_ciphers ${PROXY_SSL_PREFER_CIPHERS}; + ssl_stapling ${SSL_OCSP_STAPLING}; + ssl_stapling_verify ${SSL_OCSP_STAPLING}; - ssl_stapling ${PROXY_SSL_OCSP_STAPLING}; - ssl_stapling_verify ${PROXY_SSL_OCSP_STAPLING}; + ssl_verify_client ${SSL_VERIFY}; + ssl_verify_depth ${SSL_VERIFY_DEPTH}; - ssl_verify_client ${PROXY_SSL_VERIFY}; + PROXY_SSL_CONFIG location / { client_max_body_size 0; diff --git a/nginx/templates/includes/proxy_backend_ssl.conf.template b/nginx/templates/includes/proxy_backend_ssl.conf.template new file mode 100644 index 00000000..f105e9c8 --- /dev/null +++ b/nginx/templates/includes/proxy_backend_ssl.conf.template @@ -0,0 +1,8 @@ +proxy_ssl_certificate ${PROXY_SSL_CERT}; +proxy_ssl_certificate_key ${PROXY_SSL_CERT_KEY}; + +proxy_ssl_protocols ${PROXY_SSL_PROTOCOLS}; +proxy_ssl_ciphers ${PROXY_SSL_CIPHERS}; + +proxy_ssl_verify ${PROXY_SSL_VERIFY}; +proxy_ssl_verify_depth ${PROXY_SSL_VERIFY_DEPTH}; diff --git a/openresty/Dockerfile-alpine b/openresty/Dockerfile-alpine index f16c0d4c..f9ad0859 100644 --- a/openresty/Dockerfile-alpine +++ b/openresty/Dockerfile-alpine @@ -158,17 +158,26 @@ ENV ACCESSLOG=/var/log/nginx/access.log \ REAL_IP_HEADER="X-REAL-IP" \ REAL_IP_PROXY_HEADER="X-REAL-IP" \ REAL_IP_RECURSIVE="on" \ - PROXY_TIMEOUT=60s \ - PROXY_SSL_CERT=/usr/local/openresty/nginx/conf/server.crt \ - PROXY_SSL_CERT_KEY=/usr/local/openresty/nginx/conf/server.key \ - PROXY_SSL_DH_BITS=2048 \ - PROXY_SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ + PROXY_SSL=off \ + PROXY_SSL_CERT=/etc/nginx/conf/proxy.crt \ + PROXY_SSL_CERT_KEY=/etc/nginx/conf/proxy.key \ PROXY_SSL_CIPHERS="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ - PROXY_SSL_PREFER_CIPHERS=off \ + PROXY_SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ PROXY_SSL_VERIFY=off \ - PROXY_SSL_OCSP_STAPLING=off \ + PROXY_SSL_VERIFY_DEPTH=1 \ + PROXY_TIMEOUT=60s \ SERVER_NAME=localhost \ + SERVER_TOKENS=off \ + SSL_CERT=/etc/nginx/conf/server.crt \ + SSL_CERT_KEY=/etc/nginx/conf/server.key \ + SSL_CIPHERS="ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384" \ + SSL_DH_BITS=2048 \ + SSL_OCSP_STAPLING=off \ SSL_PORT=443 \ + SSL_PREFER_CIPHERS=off \ + SSL_PROTOCOLS="TLSv1.2 TLSv1.3" \ + SSL_VERIFY=off \ + SSL_VERIFY_DEPTH=1 \ TIMEOUT=60s \ WORKER_CONNECTIONS=1024 \ # Change this from normal nginx setup. Do not add /usr/lib or /lib