Тип сервиса
Сервис Nginx (Matomo)
Веб-сервер Nginx с обработкой запросов Matomo, связанный со средой выполнения PHP для Matomo.
Вы добавляете этот сервис в стек и выбираете там его версию и ресурсы. Каждое окружение может их переопределить.
В StackMaster
Как Nginx (Matomo) работает в StackMaster
nginx.conf to the repository: Nginx here is configured by environment variables and by the config files the service declares, not by files in the codebase.How it is configured
On every start the container renders its configuration from templates and environment variables: /etc/nginx/nginx.conf, /etc/nginx/conf.d/vhost.conf (one server), /etc/nginx/preset.conf, /etc/nginx/upstream.conf, /etc/nginx/defaults.conf and /etc/nginx/fastcgi.conf. They are rewritten on each start; never edit them in a running container.
To change the configuration:
- Set
NGINX_*environment variables on the service. - Change the
docrootsetting. - Override a declared config file: the main config template and the virtual host template of the image. Services built on this one also declare their preset template.
Preset
NGINX_VHOST_PRESET selects the location rules included in the server. This service uses html: files are served from the document root, a directory request serves the index file (NGINX_INDEX_FILE), and a path that matches no file falls back to the index file, which suits a single-page application. The image also ships the presets php, http-proxy, wordpress, laravel, matomo, django and several Drupal versions; services built on this one set the preset for their application.
Document root
The codebase is at /var/www/html. The docroot setting (variable DOCROOT_SUBDIR) names a subdirectory of the repository, and NGINX_SERVER_ROOT is set to /var/www/html/ followed by it. Leave the setting empty to serve the repository root.
Backend link
An optional link to another service sets NGINX_BACKEND_HOST and NGINX_BACKEND_PORT. They form the upstream only for presets that have one: the PHP presets pass PHP requests to it over FastCGI, http-proxy and django proxy HTTP to it. With the html preset the upstream is empty and the link has no effect.
Always present
Unless NGINX_VHOST_NO_DEFAULTS is set, these rules apply with every preset:
/.healthzreturns 204. Use it for health checks.- Paths that start with a dot are denied, except
/.well-known/.NGINX_ALLOW_ACCESS_HIDDEN_FILESlifts the rule.wodby.ymlandMakefileare denied. /favicon.icoreturns an empty image when the file is missing.- Response headers
X-XSS-Protection,X-Frame-Options,X-Content-Type-OptionsandContent-Security-Policyare added. The policy only restricts framing; setNGINX_HEADERS_CONTENT_SECURITY_POLICYto change it orNGINX_NO_DEFAULT_HEADERSto drop all four.
Variables that matter most
| Variable | Effect |
|---|---|
NGINX_CLIENT_MAX_BODY_SIZE | largest accepted request body, such as an upload |
NGINX_STATIC_EXT_REGEX | file extensions treated as static files |
NGINX_STATIC_EXPIRES | cache lifetime sent with static files |
NGINX_DISABLE_CACHING | sends no-cache headers for everything |
NGINX_INDEX_FILE | index file |
NGINX_ERROR_403_URI, NGINX_ERROR_404_URI | custom error pages |
NGINX_SERVER_EXTRA_CONF_FILEPATH | an extra file included in the server block |
NGINX_SET_REAL_IP_FROM, NGINX_REAL_IP_HEADER | trusted proxy and the header holding the client address |
NGINX_GZIP, NGINX_BROTLI | response compression |
Access and error logs go to the container's standard output and error.
Build and reaching the service
- The image is built from the connected repository: the codebase is copied into the image at
/var/www/html. Files are served from the built image, so a change needs a new build and deployment. - Other services reach it over HTTP on port 80 at the app service's name inside the environment.
Check the result
nginx -Tprints the configuration in effect.curl -sI localhost/.healthzreturns 204 from inside the container.
Nginx for Matomo on Wodby
What this service adds to the Nginx service it is based on.
Preset
The service sets NGINX_VHOST_PRESET to matomo, the image's rule set for Matomo. Its template is declared as a config file of this service and can be overridden there. What it does:
- Only these scripts run as PHP:
index.php,matomo.php,piwik.php,js/index.phpandplugins/HeatmapSessionRecording/configs.php. Every other.phppath returns 403. - The directories
config,tmp,coreandlangare denied. - Under
libs,vendor,plugins,miscandnode_modules, only files with a static extension are served; everything else there is denied. The static extensions of this preset includejsonandhtml. - Tag Manager preview containers (
js/container_*_preview.js) are sent with caching disabled. - A path that matches no file returns 404. There is no fallback to
index.php.
Backend link and build
- The required backend link must point to the Matomo PHP service. It sets
NGINX_BACKEND_HOSTandNGINX_BACKEND_PORT, which form the FastCGI upstream. - This service has no repository of its own: its image is built from the source of the linked Matomo service, copied to
/var/www/html. Its.dockerignoreleaves outvendor,node_modules,core,tests,console, the Composer and npm manifests and dot files, so those are not in the web server image. - The
docrootsetting of the Nginx service applies; leave it empty for a Matomo codebase at the repository root.
A file that Matomo writes at run time in the PHP service's container, for example a plugin installed from the interface, is not in this service's image.
Check the result
nginx -Tshows the preset and upstream in effect.curl -sI localhost/matomo.phpfrom inside the container returns Matomo's response when the PHP service is reachable.
Обзор
Технический профиль Nginx (Matomo)
Версии
Основан на
Репозиторий исходного кода
Публичный Helm-чарт
Стеки
Стеки, в которые входит Nginx (Matomo)
Конфигурация
Конфигурация сервиса Nginx (Matomo)
Технические домены
Файлы конфигурации
Настройки
Связи сервиса
Каждая связь — это подключение Nginx (Matomo) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.
backend
Сервисы, которые подходят для этой связи