Skip to content

fix(nginx plugin): place mime.types next to nginx.conf so include resolves#2918

Open
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-srxxak
Open

fix(nginx plugin): place mime.types next to nginx.conf so include resolves#2918
mikeland73 wants to merge 2 commits into
mainfrom
claude/focused-goldberg-srxxak

Conversation

@mikeland73

@mikeland73 mikeland73 commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2908.

The nginx plugin's service fails to start because it can't find mime.types:

[emerg] open() "/tmp/testnginx/devbox.d/nginx/mime.types" failed (2: No such file or directory) in .../devbox.d/nginx/nginx.conf:6

PR #2844 added include mime.types; to nginx.conf and created the mime.types file under {{ .Virtenv }} (.devbox/virtenv/nginx/), on the assumption that nginx -p $NGINX_PATH_PREFIX would make the include resolve relative to the prefix. As the reporter (@jefft) correctly diagnosed, nginx only uses the -p prefix for runtime paths (error_log, access_log, root, …). At configuration time, relative paths in include are resolved relative to the directory of nginx.conf itself — which is {{ .DevboxDir }} (devbox.d/nginx/), not the virtenv. So the include pointed at a file that wasn't there.

Fix

mime.types needs to sit next to nginx.conf in $NGINX_CONFDIR. Simply moving the create_files destination to {{ .DevboxDir }} would fix fresh installs but not existing ones: Manager.shouldCreateFile() (internal/plugin/plugin.go:241-243) skips creating any devbox.d/ file once a plugin is installed (PluginVersion set in devbox.lock), even when the file is missing, and the version bump doesn't reset that.

Instead, this PR does the copy at service-startup time from files that always live under .devbox (which is regenerated on every env compute):

  • mime.types continues to be created in the virtenv ({{ .Virtenv }}/mime.types), which is always regenerated.
  • plugins/nginx/process-compose.yaml — also regenerated under .devbox — copies mime.types into $NGINX_CONFDIR next to nginx.conf when it's missing, before starting nginx:
    if [ ! -f $NGINX_CONFDIR/mime.types ] && [ -f $NGINX_PATH_PREFIX/mime.types ]; then cp $NGINX_PATH_PREFIX/mime.types $NGINX_CONFDIR/mime.types; fi
  • Add the mime.types file to the checked-in nginx server example so it works out of the box.
  • Bump the plugin version 0.0.50.0.6.

This remediates both fresh installs and projects that already have nginx installed.

How was it tested?

Reproduced the failure and verified the fix by following the issue's repro steps:

mkdir /tmp/testnginx && cd /tmp/testnginx
devbox init
devbox add nginx
devbox services up -b
tail -1 .devbox/virtenv/nginx/error.log   # no more mime.types emerg error
devbox services down

With the change, mime.types is copied to devbox.d/nginx/mime.types next to nginx.conf at service start, the include resolves, and the service starts cleanly. The change is limited to plugin data files (JSON config, process-compose YAML, and a static mime.types); no Go code paths are affected.

/cc @jefft (issue reporter) — thanks for the precise diagnosis.

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.

🤖 Generated with Claude Code

https://claude.ai/code/session_017uK5pHhERaRaoDAvNdw9ww

…olves

nginx resolves include directives relative to the config file's directory,
not the -p prefix path. The mime.types file was created in the virtenv
($NGINX_PATH_PREFIX) while nginx.conf lives in the devbox.d dir, so
`include mime.types;` failed with 'No such file or directory' and the
service could not start.

Move the create_files destination for mime.types from {{ .Virtenv }} to
{{ .DevboxDir }} so it sits alongside nginx.conf, and add the file to the
nginx example project. Bump the plugin version to 0.0.6.

Fixes #2908

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uK5pHhERaRaoDAvNdw9ww
Copilot AI review requested due to automatic review settings July 11, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the nginx plugin failing to start due to include mime.types; resolving relative to nginx.conf’s directory (devbox.d/nginx/) rather than the -p prefix (.devbox/virtenv/nginx/). It relocates where the plugin scaffolds mime.types so the include can resolve correctly, and updates the nginx example accordingly.

Changes:

  • Bump nginx plugin version to 0.0.6.
  • Generate mime.types into devbox.d/nginx/ (next to nginx.conf) instead of the virtenv.
  • Add mime.types to the checked-in nginx server example so it works out of the box.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
plugins/nginx.json Moves mime.types creation to {{ .DevboxDir }} and bumps plugin version to match the fix.
examples/servers/nginx/devbox.d/nginx/mime.types Adds the mime.types file to the nginx example so include mime.types; resolves correctly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/nginx.json
Comment on lines 16 to 18
"{{ .Virtenv }}/temp": "",
"{{ .Virtenv }}/mime.types": "nginx/mime.types",
"{{ .DevboxDir }}/mime.types": "nginx/mime.types",
"{{ .Virtenv }}/process-compose.yaml": "nginx/process-compose.yaml",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — confirmed against internal/plugin/plugin.go:241-243: shouldCreateFile() returns false for any devbox.d/ path once the plugin is installed (PluginVersion != ""), and the version bump doesn't reset that (it's a non-empty check, not a version comparison). So placing mime.types in {{ .DevboxDir }} would leave existing installs broken.

I've switched to your option (b): mime.types stays in the virtenv ({{ .Virtenv }}, under .devbox, always regenerated), and process-compose.yaml — also regenerated under .devbox — now copies it into $NGINX_CONFDIR next to nginx.conf at service start when missing:

if [ ! -f $NGINX_CONFDIR/mime.types ] && [ -f $NGINX_PATH_PREFIX/mime.types ]; then cp $NGINX_PATH_PREFIX/mime.types $NGINX_CONFDIR/mime.types; fi

This remediates both fresh and already-installed projects. Pushed in b39af3a.


Generated by Claude Code

Keep mime.types in the virtenv (which lives under .devbox and is always
regenerated) and copy it into $NGINX_CONFDIR at service startup when
missing, instead of relying on create_files to place it in devbox.d.

Manager.shouldCreateFile() skips creating any devbox.d file once a plugin
is installed (PluginVersion set in devbox.lock), so placing mime.types in
{{ .DevboxDir }} would not remediate existing nginx installs. Doing the
copy from process-compose.yaml — also regenerated under .devbox — fixes
both fresh and already-installed projects.

Addresses review feedback on #2908.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

nginx plugin broken due to misplaced mime.types

3 participants