Skip to content

2.1.2 — Per-project Nginx config

Choose a tag to compare

@FernandoEbert FernandoEbert released this 11 Nov 05:46
· 14 commits to master since this release
80ce7cf

Per-project Nginx config override

A site can now ship its own Nginx server block inside the project (<project>/nginx/<site>.<tld>.conf) instead of editing the file Valet generates in ~/.config/valet/Nginx. Previously, any valet secure|unsecure|isolate|unisolate|domain|install regenerated the site config and discarded manual changes (#8).

Command Description
valet nginx:publish [site] [--force] Publishes Valet's default config for the current site state (plain, secured, isolated or both) into <project>/nginx/<site>.conf, keeping the VALET_* placeholders. Refuses to overwrite without --force.
valet nginx [site] Activates the project config: renders placeholders, writes the site config, validates with nginx -t (rolls back on failure) and restarts Nginx.
valet nginx:reset [site] Deactivates the project config and restores Valet's default (keeps isolation). The project file is kept.

All commands default to the current directory. Once active, the project template is re-rendered automatically on secure, unsecure, isolate, unisolate, domain and install, and valet isolated / which-php keep working.

Available placeholders: VALET_SITE, VALET_PROJECT_PATH, VALET_HOME_PATH, VALET_SERVER_PATH, VALET_STATIC_PREFIX, VALET_CERT, VALET_KEY, VALET_FPM_SOCKET_FILE, VALET_ISOLATED_PHP_VERSION, VALET_HTTP_PORT, VALET_HTTPS_PORT, VALET_REDIRECT_PORT.

Sites without an active project config behave exactly as before.

Known limitations

  • The template name includes the TLD: after valet domain, the rendered config is kept, but valet nginx will look for <site>.<new-tld>.conf.
  • nginx -t validates the whole Nginx config, so a broken config from another site also triggers the rollback.

Other changes

Upgrading

composer global update fernandoebert/valet-linux-plus
valet install