App service
Services/Nginx (Angular)

Nginx (Angular) service

Nginx-based frontend service for building Angular apps from source and serving the compiled site.

Use it as a versioned stack building block that can build from source, plug into CI/CD, and connect to external providers without hardcoding secrets into the codebase.

On Wodby

How Nginx (Angular) runs on Wodby

What Wodby sets up for this web server. Check it before adding an 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 docroot setting.
  • 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:

  • /.healthz returns 204. Use it for health checks.
  • Paths that start with a dot are denied, except /.well-known/. NGINX_ALLOW_ACCESS_HIDDEN_FILES lifts the rule. wodby.yml and Makefile are denied.
  • /favicon.ico returns an empty image when the file is missing.
  • Response headers X-XSS-Protection, X-Frame-Options, X-Content-Type-Options and Content-Security-Policy are added. The policy only restricts framing; set NGINX_HEADERS_CONTENT_SECURITY_POLICY to change it or NGINX_NO_DEFAULT_HEADERS to drop all four.

Variables that matter most

VariableEffect
NGINX_CLIENT_MAX_BODY_SIZElargest accepted request body, such as an upload
NGINX_STATIC_EXT_REGEXfile extensions treated as static files
NGINX_STATIC_EXPIREScache lifetime sent with static files
NGINX_DISABLE_CACHINGsends no-cache headers for everything
NGINX_INDEX_FILEindex file
NGINX_ERROR_403_URI, NGINX_ERROR_404_URIcustom error pages
NGINX_SERVER_EXTRA_CONF_FILEPATHan extra file included in the server block
NGINX_SET_REAL_IP_FROM, NGINX_REAL_IP_HEADERtrusted proxy and the header holding the client address
NGINX_GZIP, NGINX_BROTLIresponse 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 -T prints the configuration in effect.
  • curl -sI localhost/.healthz returns 204 from inside the container.

Angular on Wodby

What this service adds to the Nginx service it is based on. A deployed environment serves the application's static build with Nginx. A development workspace runs something else: the Angular CLI development server, in a Node.js image.

Deployed environments

  • The service has no Dockerfile and runs no Node.js process. The image is the Nginx image with files copied into /var/www/html, its document root.
  • The pipeline produces those files: it installs dependencies and runs the production build in a Node.js container, then builds the image from the output directory only (dist/<project>/browser in the Angular boilerplate). Source files and node_modules are not in the image.
  • A change to the name or location of the build output must be made in the pipeline's wodby ci build --from step as well, or the image is built from the wrong directory.
  • Requests for paths that are not files are answered with index.html, so client-side routes work without extra Nginx configuration.
  • The application is built before deployment and runs in the browser. Environment variables of the service, including WODBY_*, do not reach it at run time. Values it needs must be in the build, or fetched from an API.

Variables the service sets

PORT and NODE_PORT (both 8080) and WORKSPACE_NODE_COMMAND. They are used by the development workspace only; Nginx ignores them.

In a development workspace

  • The container runs a Node.js development image instead of Nginx, with the checkout mounted at /usr/src/app. Nginx, its configuration and the pipeline's build step are not involved.
  • Workspace setup installs dependencies with workspace-node prepare. The package manager is taken from packageManager in package.json, otherwise from the lockfile, and the install follows the lockfile exactly, with development dependencies. Run it again after changing dependencies.
  • The application is started with ng serve --host "$HOST" --port "$PORT" --poll 1000, called directly from node_modules/@angular/cli, not through the start script of package.json. Options in that script do not apply; options in angular.json do.
  • The development server listens on 0.0.0.0:8080, and the container's health checks probe that port. Do not change the port in the project configuration.
  • File watching uses polling, so a saved file is rebuilt without a restart.
  • The development server must accept the environment's host name. The start command does not pass one: allow the hosts of the environment in the serve options of angular.json (allowedHosts) when the server rejects the preview host.
  • NODE_ENV is development.
  • To start the server differently, set WORKSPACE_NODE_COMMAND on the service. The command must listen on $HOST:$PORT and configure polling itself.

Overview

Technical profile and packaging

This page shows how Nginx (Angular) 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

1.31, 1.30

Ports and protocols

80/HTTP

Labels

angular, nginx, nginx

Stacks

Use it inside ready-made stacks or your own

These public stacks already include Nginx (Angular) 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.

CI/CD

Build from source and ship changes without extra glue work

Nginx (Angular) can build from source as part of a stack. Start from a compatible public boilerplate or connect your repository and keep CI/CD and image storage inside the same Wodby workflow.

Angular boilerplate

Start from a working boilerplate instead of wiring the build process from scratch.

wodby/angular-boilerplate

Git providers

Connect repositories from supported Git providers when this service should build from your own codebase.

CI providers

Wodby CI is the default path, but external CI providers can fit the same build and release workflow when that suits your team better.

Container registries

Keep built images in Wodby Registry by default or store them in another registry without changing how the service is built.

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

2 configs can be versioned with the service.

Settings

1 setting can be overridden per environment.