Skip to content

fix(nginx plugin): include mime.types so static files get correct Content-Type#2844

Merged
mikeland73 merged 2 commits into
mainfrom
claude/focused-goldberg-8Kb39
Jun 6, 2026
Merged

fix(nginx plugin): include mime.types so static files get correct Content-Type#2844
mikeland73 merged 2 commits into
mainfrom
claude/focused-goldberg-8Kb39

Conversation

@mikeland73
Copy link
Copy Markdown
Collaborator

Summary

Fixes #2693.

The nginx plugin generated an nginx.conf that did not include a mime.types map. As a result, nginx fell back to its default type and served every static file (CSS, JS, images, fonts, …) with Content-Type: text/plain, so browsers wouldn't apply stylesheets or run scripts.

What changed

  • Added a standard mime.types file to the plugin (plugins/nginx/mime.types).
  • The plugin now creates it in the virtenv via create_files ({{ .Virtenv }}/mime.types).
  • Added include mime.types; to the generated http { … } block in both nginx.template and nginx.conf.
  • Bumped the plugin version 0.0.40.0.5.
  • Updated the checked-in examples/servers/nginx config to stay consistent.

Why the virtenv (and a relative include)

The plugin launches nginx with nginx -p $NGINX_PATH_PREFIX …, where NGINX_PATH_PREFIX is the plugin's virtenv. nginx resolves relative paths against that prefix — which is exactly how the existing error_log error.log, access_log access.log, and temp/* paths already work. Placing mime.types in the virtenv and using a plain include mime.types; keeps the fix consistent with that convention and requires no new env var. The virtenv copy is also regenerated on every run, so it stays in sync with the plugin.

Note: The drupal example stack already ships its own mime.conf, so it was left untouched. This change targets the default nginx plugin output described in the issue.

How to verify

devbox add nginx
echo 'body{color:red}' > devbox.d/web/my.css
devbox services up
curl -I http://localhost:8081/my.css   # now: Content-Type: text/css

Testing

  • go build ./... passes.
  • Plugin unit tests pass except for two pre-existing TestGitPluginFileContentCache* tests that fail only because they make local git commits (commit signing is unavailable in this CI sandbox) — unrelated to this change.

cc @ThomasLohner (issue reporter) — thanks for the clear repro!


Generated by Claude Code

…tent-Type

The nginx plugin generated an nginx.conf without a `mime.types` include, so
nginx served every static file (css, js, images, etc.) with
`Content-Type: text/plain`.

This adds a standard `mime.types` file to the plugin's virtenv and includes
it from the generated config. The file is placed in the virtenv (the nginx
`-p` prefix dir), so the existing relative-path convention used for
`error.log`, `access.log` and the `temp/*` paths applies to the
`include mime.types;` directive as well.

Fixes #2693
Copilot AI review requested due to automatic review settings June 2, 2026 14:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 incorrect Content-Type headers for static assets served by the built-in nginx plugin by ensuring nginx loads a mime.types map at runtime (addressing #2693). It aligns the generated plugin config and the checked-in nginx example so that CSS/JS/images/fonts are served with the correct MIME type.

Changes:

  • Add plugins/nginx/mime.types and ensure it’s created into the plugin virtenv via create_files.
  • Include mime.types in the generated http { ... } block in both the template and the checked-in default config.
  • Bump the nginx plugin version to 0.0.5 and update the nginx example configs accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
plugins/nginx/nginx.template Adds include mime.types; in the http block so envsubst-generated configs load MIME mappings.
plugins/nginx/nginx.conf Adds include mime.types; to the default checked-in config copied to devbox.d/nginx.
plugins/nginx/mime.types New MIME type mapping file to be included by nginx at runtime.
plugins/nginx.json Bumps plugin version and ensures mime.types is created under {{ .Virtenv }}.
examples/servers/nginx/devbox.d/nginx/nginx.template Keeps the example template consistent by including mime.types.
examples/servers/nginx/devbox.d/nginx/nginx.conf Keeps the example generated config consistent by including mime.types.

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

@mikeland73 mikeland73 requested review from Lagoja and gcurtis June 2, 2026 15:46
@mikeland73 mikeland73 merged commit 75f5ed8 into main Jun 6, 2026
24 checks passed
@mikeland73 mikeland73 deleted the claude/focused-goldberg-8Kb39 branch June 6, 2026 00:29
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: Generated config is missing mime.types

4 participants