Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx mime-type is not the same as Apache one #11400

Closed
tzerber opened this issue Dec 14, 2023 · 1 comment · Fixed by #10408
Closed

Nginx mime-type is not the same as Apache one #11400

tzerber opened this issue Dec 14, 2023 · 1 comment · Fixed by #10408

Comments

@tzerber
Copy link

tzerber commented Dec 14, 2023

Hey everyone,

During other bug-hunting in the docker section, i noticed the mime-type in apache for js / mjs is the RFC correct one "text/javascript" but the nginx one is still "application/javascript" and it causes quite a lot of errors.
I know Nginx is not officially supported webserver, but it's commonly used with docker.

According to this the config claims to add

types {
        text/javascript js mjs;
    }

this to the config, but that causes errors in docker like

nginx: [warn] duplicate extension "js", content type: "text/javascript", previous content type: "application/javascript" in /etc/nginx/nginx.conf:19

As a somewhat temporary solution i changed the config like this to get rid of the errors

location ~* \.(?:js|mjs)$ {
            types { 
                text/javascript js mjs;
            } 
            try_files $uri /index.php$request_uri;
            add_header Cache-Control "public, max-age=15778463, $asset_immutable";
            access_log off;
        }

        # Serve static files
        location ~ \.(?:css|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
            try_files $uri /index.php$request_uri;
            add_header Cache-Control "public, max-age=15778463, $asset_immutable";
            access_log off;     # Optional: Don't log access to assets

            location ~ \.wasm$ {
                default_type application/wasm;
            }
        }

Not opening a pull request, because I'm not that much expert on nginx myself and i might be wrong here, but that fixed it. I believe after some time nginx will update their mime.types, but for the time being i think it's worth mentioning this in the docs, because only today I've seen at least 10 different people over at least 3 different issues having problems with that.

@joshtrichards
Copy link
Member

Technically I'm fairly certain it's just a warning because we're redefining it, but I agree it would be nice to eliminate.

There's a relevant existing PR (#10408). Can you test the approach in #10408? It just drops js entirely from our base config.

I don't recall all the history at the moment, but for the record: https://trac.nginx.org/nginx/ticket/1407

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants