Skip to content

Commit 406208e

Browse files
committed
fix(nginx plugin): include mime.types so static files get correct Content-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
1 parent 35d57a3 commit 406208e

6 files changed

Lines changed: 104 additions & 1 deletion

File tree

examples/servers/nginx/devbox.d/nginx/nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
events {}
22
http{
3+
include mime.types;
34
server {
45
listen 8080;
56
listen [::]:8080;

examples/servers/nginx/devbox.d/nginx/nginx.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
events {}
22
http{
3+
include mime.types;
34
server {
45
listen $NGINX_WEB_PORT;
56
listen [::]:$NGINX_WEB_PORT;

plugins/nginx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nginx",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "nginx can be configured with env variables\n\nTo customize:\n* Use $NGINX_CONFDIR to change the configuration directory\n* Use $NGINX_TMPDIR to change the tmp directory. Use $NGINX_USER to change the user\n* Use $NGINX_WEB_PORT to change the port NGINX runs on. \n Note: This plugin uses envsubst when running `devbox services` to generate the nginx.conf file from the nginx.template file. To customize the nginx.conf file, edit the nginx.template file.\n",
55
"packages": ["gettext@latest", "gawk@latest"],
66
"env": {
@@ -14,6 +14,7 @@
1414
},
1515
"create_files": {
1616
"{{ .Virtenv }}/temp": "",
17+
"{{ .Virtenv }}/mime.types": "nginx/mime.types",
1718
"{{ .Virtenv }}/process-compose.yaml": "nginx/process-compose.yaml",
1819
"{{ .DevboxDir }}/nginx.template": "nginx/nginx.template",
1920
"{{ .DevboxDir }}/nginx.conf": "nginx/nginx.conf",

plugins/nginx/mime.types

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
types {
2+
text/html html htm shtml;
3+
text/css css;
4+
text/xml xml;
5+
image/gif gif;
6+
image/jpeg jpeg jpg;
7+
application/javascript js;
8+
application/atom+xml atom;
9+
application/rss+xml rss;
10+
11+
text/mathml mml;
12+
text/plain txt;
13+
text/vnd.sun.j2me.app-descriptor jad;
14+
text/vnd.wap.wml wml;
15+
text/x-component htc;
16+
17+
image/avif avif;
18+
image/png png;
19+
image/svg+xml svg svgz;
20+
image/tiff tif tiff;
21+
image/vnd.wap.wbmp wbmp;
22+
image/webp webp;
23+
image/x-icon ico;
24+
image/x-jng jng;
25+
image/x-ms-bmp bmp;
26+
27+
font/woff woff;
28+
font/woff2 woff2;
29+
30+
application/java-archive jar war ear;
31+
application/json json;
32+
application/mac-binhex40 hqx;
33+
application/msword doc;
34+
application/pdf pdf;
35+
application/postscript ps eps ai;
36+
application/rtf rtf;
37+
application/vnd.apple.mpegurl m3u8;
38+
application/vnd.google-earth.kml+xml kml;
39+
application/vnd.google-earth.kmz kmz;
40+
application/vnd.ms-excel xls;
41+
application/vnd.ms-fontobject eot;
42+
application/vnd.ms-powerpoint ppt;
43+
application/vnd.oasis.opendocument.graphics odg;
44+
application/vnd.oasis.opendocument.presentation odp;
45+
application/vnd.oasis.opendocument.spreadsheet ods;
46+
application/vnd.oasis.opendocument.text odt;
47+
application/vnd.openxmlformats-officedocument.presentationml.presentation
48+
pptx;
49+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
50+
xlsx;
51+
application/vnd.openxmlformats-officedocument.wordprocessingml.document
52+
docx;
53+
application/vnd.wap.wmlc wmlc;
54+
application/wasm wasm;
55+
application/x-7z-compressed 7z;
56+
application/x-cocoa cco;
57+
application/x-java-archive-diff jardiff;
58+
application/x-java-jnlp-file jnlp;
59+
application/x-makeself run;
60+
application/x-perl pl pm;
61+
application/x-pilot prc pdb;
62+
application/x-rar-compressed rar;
63+
application/x-redhat-package-manager rpm;
64+
application/x-sea sea;
65+
application/x-shockwave-flash swf;
66+
application/x-stuffit sit;
67+
application/x-tcl tcl tk;
68+
application/x-x509-ca-cert der pem crt;
69+
application/x-xpinstall xpi;
70+
application/xhtml+xml xhtml;
71+
application/xspf+xml xspf;
72+
application/zip zip;
73+
74+
application/octet-stream bin exe dll;
75+
application/octet-stream deb;
76+
application/octet-stream dmg;
77+
application/octet-stream iso img;
78+
application/octet-stream msi msp msm;
79+
80+
audio/midi mid midi kar;
81+
audio/mpeg mp3;
82+
audio/ogg ogg;
83+
audio/x-m4a m4a;
84+
audio/x-realaudio ra;
85+
86+
video/3gpp 3gpp 3gp;
87+
video/mp2t ts;
88+
video/mp4 mp4;
89+
video/mpeg mpeg mpg;
90+
video/quicktime mov;
91+
video/webm webm;
92+
video/x-flv flv;
93+
video/x-m4v m4v;
94+
video/x-mng mng;
95+
video/x-ms-asf asx asf;
96+
video/x-ms-wmv wmv;
97+
video/x-msvideo avi;
98+
}

plugins/nginx/nginx.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
events {}
55
http{
6+
include mime.types;
67
server {
78
listen 8081;
89
listen [::]:8081;

plugins/nginx/nginx.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
events {}
55
http{
6+
include mime.types;
67
server {
78
listen $NGINX_WEB_PORT;
89
listen [::]:$NGINX_WEB_PORT;

0 commit comments

Comments
 (0)