App service
Services/Nginx (Moodle)

Nginx (Moodle) service

Nginx web service with Moodle request handling, linked to the Moodle PHP runtime.

Use it as a reusable, versioned service inside custom or predefined stacks so teams can keep the runtime and operational model consistent.

On Wodby

How Nginx (Moodle) runs on Wodby

An Nginx server that passes HTTP requests to one linked service. It serves no application files and is not built from a repository.

How it works

  • The required backend link sets NGINX_BACKEND_HOST and NGINX_BACKEND_PORT to the linked service's host and port. They form the only upstream.
  • The service sets NGINX_VHOST_PRESET to http-proxy. Requests are passed to the backend over HTTP with the headers Host, X-Forwarded-For and X-Forwarded-Proto. The backend must listen on the port of its endpoint and should read the scheme and client address from those headers.
  • The preset sets no Upgrade or Connection headers.

The configuration is rendered from templates and environment variables on every start, into /etc/nginx/nginx.conf, /etc/nginx/conf.d/vhost.conf, /etc/nginx/preset.conf and /etc/nginx/upstream.conf. Never edit these files in a running container.

Requests that do not reach the backend

The image's default rules are answered by Nginx itself:

  • /.healthz returns 204. It reports on the proxy, not on the backend.
  • /favicon.ico, /robots.txt, /humans.txt, /ads.txt, /llms.txt, everything under /.well-known/, and paths ending in .flv, .mp4, .m4a or .mov are looked up on the proxy's own disk, where there are no application files: a missing favicon gets an empty image, the others are not found.
  • Other paths that start with a dot are denied, as are wodby.yml and Makefile.

Set NGINX_VHOST_NO_DEFAULTS on the service when the backend must answer these paths itself.

Nginx also adds the response headers X-XSS-Protection, X-Frame-Options, X-Content-Type-Options and a Content-Security-Policy that forbids framing. Set NGINX_HEADERS_CONTENT_SECURITY_POLICY to change the policy, or NGINX_NO_DEFAULT_HEADERS to leave headers to the backend.

Changing configuration

  • Environment variables on the service. The ones that matter most for a proxied application: NGINX_CLIENT_MAX_BODY_SIZE (largest accepted request body), NGINX_BACKEND_FAIL_TIMEOUT, NGINX_SET_REAL_IP_FROM and NGINX_REAL_IP_HEADER, NGINX_GZIP.
  • The two declared config files: the main config template and the virtual host template.

Other services reach the proxy over HTTP on port 80 at the app service's name inside the environment.

Check the result

  • nginx -T prints the configuration in effect, including the upstream.
  • curl -sI localhost/.healthz returns 204 from inside the container.

Nginx for Moodle on Wodby

What this service adds to the Nginx Proxy service it is based on.

Image and rules

The service runs the Nginx variant of the wodby/moodle image (5.3-nginx-rN): Nginx with Moodle's public directory, for the Moodle release of the same version as the Moodle service. Keep both services on the same release.

Moodle's rules are the image's PHP preset, /etc/gotpl/presets/php.conf.tmpl. They are the preset config file of this service and can be overridden there. The service sets the preset name php (NGINX_VHOST_PRESET), which also makes the image point the php upstream at the linked Moodle service.

  • PHP scripts are passed to PHP-FPM with the path that follows them, so Moodle's slash arguments work, for example /pluginfile.php/12/mod_resource/content/0/file.pdf and /theme/styles.php/boost/….
  • Requests for paths and scripts that don't exist go to Moodle's router, r.php, as Moodle 5.1 and later require. Moodle's JavaScript modules under /core/esm/ are served that way.
  • Files Moodle keeps in its web root but must not serve return 404: vendor, node_modules, composer.json, readme and upgrade notes, db/install.xml, test fixtures, phpunit.xml, lock files and environment.xml. Hidden files return 403.
  • Other static files are served by Nginx with a one-year cache lifetime.

Document root

NGINX_SERVER_ROOT is /var/www/html/public, Moodle's web root. config.php, admin/cli and the rest of the code are not in this image.

Uploads

NGINX_CLIENT_MAX_BODY_SIZE is 256m, the same limit as the Moodle PHP service.

Check the result

  • nginx -T shows the rules and document root in effect.
  • Site administration > Server > Environment in Moodle reports no router warning.

Overview

Technical profile and packaging

This page shows how Nginx (Moodle) is packaged and versioned as a Wodby service, what it exposes at runtime, and which source artifacts it builds on.

Service type

App service

Versions

5.3

Ports and protocols

80/HTTP

Labels

moodle, nginx, proxy

Stacks

Use it inside ready-made stacks or your own

These public stacks already include Nginx (Moodle) as part of their default service model. You can start there and customize the stack, or compose your own stack around the same building block.

Runtime wiring

Reuse connectivity, storage, and runtime defaults

This service can expose ports, connect to other services, attach persistent storage, and define runtime defaults that become reusable inside stacks rather than being rebuilt case by case.

Endpoints

80/HTTP

Technical domains

HTTP endpoints from this service can use technical domains with auto-renewed TLS certificates on Wodby.

Configs

3 configs can be versioned with the service.

Service links

These links define which other services can connect to Nginx (Moodle) when it is used inside a stack.