# Is there a length limitation on file extensions?

**URL:** <https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220>\
**Category:** NGINX\
**Created:** [March 7, 2016, 11:04pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220 "2016-03-07T23:04:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [March 7, 2016, 11:04pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/1 "2016-03-07T23:04:26Z")

</div>

I am using Nginx to serve a website that hosts a .Net application. The  
file  
a user needs to download and that triggers installation is a  
\*.application  
file, and an MS Internet Information Server associates that with the  
mime  
type application/x-ms-application. However that file never gets any  
Content-Type header. I edited the mime.types configuration file to  
include  
that, but Nginx ignores that. When I rename the file to .app, and use a  
mime  
type definition for that file it works. I also tried various other file  
extensions of varying length, and it looks like there is a limit of 10  
characters in a file type extenion of Nginx, and if that is exceeded  
there  
will be no Content-Type header.  
Is my assumption correct? Where is this in the source files? (I know how  
to  
compile Nginx). Or any other idea what causes my problem?  
Thanks, Joachim

Posted at Nginx Forum:

> **[Is there a length limitation on file extensions?](https://forum.nginx.org/read.php?2,265148,265148#msg-265148)**
>
> I am using Nginx to serve a website that hosts a .Net application. The file a user needs to download and that triggers installation is a \*.application file, and an MS Internet Information Server associates that with the mime type...

---

<div class="post-metadata">

**Author:** ![j.o.l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@j.o.l](https://www.ruby-forum.com/u/j.o.l)\
**Post date:** [March 7, 2016, 11:34pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/2 "2016-03-07T23:34:49Z")

</div>

j.o.l:

> Is my assumption correct? Where is this in the source files? (I know how to  
> compile Nginx). Or any other idea what causes my problem?  
> Thanks, Joachim

works here, so your assumption seems wrong.

server {  
listen \*:80;  
server\_name localhost;  
location / {  
autoindex on;  
alias /tmp/;  
}  
types {  
application/x-ms-executable application;  
}  
}

$ touch /tmp/foo.application

$ curl -I localhost/foo.application  
HTTP/1.1 200 OK  
Server: nginx  
Date: Mon, 07 Mar 2016 22:29:42 GMT  
Content-Type: application/x-ms-executable  
Content-Length: 0  
Last-Modified: Mon, 07 Mar 2016 22:26:52 GMT  
Connection: keep-alive  
Accept-Ranges: bytes

$

---

<div class="post-metadata">

**Author:** ![j.o.l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@j.o.l](https://www.ruby-forum.com/u/j.o.l)\
**Post date:** [March 8, 2016, 9:35pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/3 "2016-03-08T21:35:04Z")

</div>

Thanks a lot for providing a working example. I reproduced it and yes  
works  
with that server block. Then I tried to change until I discovered the  
following. Here is my server block:

```
    server {
            listen 443 ssl;
            listen 8080;
            server_name xxx;
            ssl_certificate /etc/letsencrypt/live/xxx/fullchain.pem;
            ssl_certificate_key 

```

/etc/letsencrypt/live/xxx/privkey.pem;  
root /usr/local/nginx/conf/websites/xxx;  
autoindex on;  
types {  
application/x-ms-application application;  
}  
}

When I access that server using http, Content-Type is returned as  
defined,  
when accessing it via https, Content-Type is missing. Strange, isn´t it?  
Btw. I am using nginx 1.8.0.

Posted at Nginx Forum:

> **[Re: Is there a length limitation on file extensions?](https://forum.nginx.org/read.php?2,265148,265162#msg-265162)**
>
> I am using Nginx to serve a website that hosts a .Net application. The file a user needs to download and that triggers installation is a \*.application file, and an MS Internet Information Server associates that with the mime type...

---

<div class="post-metadata">

**Author:** ![j.o.l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@j.o.l](https://www.ruby-forum.com/u/j.o.l)\
**Post date:** [March 9, 2016, 5:18pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/4 "2016-03-09T17:18:01Z")

</div>

Are you sure this configuration gets loaded (nginx -t OK, no error on  
configuration -re-loading)?

You could try to replace your types block with an empty one (to override  
defaults if they are defined at upper level, or simply remove them) and  
add  
the following directive:  
default\_type application/x-ms-application

## You should se the Content-Encoding set to this special value by requesting with HTTP on port 8080 and HTTPS on port 443. If you get anything different, your request is probably served elsewhere.

_B. R._

---

<div class="post-metadata">

**Author:** ![j.o.l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@j.o.l](https://www.ruby-forum.com/u/j.o.l)\
**Post date:** [March 9, 2016, 7:07pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/5 "2016-03-09T19:07:16Z")

</div>

yes, nginx -t reports OK.  
I tried the empty types block with default\_type as suggested - no change  
to  
the behavior.  
I verified that there is no other block processing the request. There is  
no  
other block that uses that certificate on port 443, and the port 8080 is  
used for that server block only. I also added an access\_log to that  
server  
block redirecting output to a different file, and yes, the output goes  
to  
that different file. I even defined my own log\_format that logs  
$sent\_http\_content\_type, and it reports application/x-ms-application for  
http, and - when using https…  
Any other idea what to try or check?  
Thanks a lot!

Posted at Nginx Forum:

> **[Re: Is there a length limitation on file extensions?](https://forum.nginx.org/read.php?2,265148,265197#msg-265197)**
>
> I am using Nginx to serve a website that hosts a .Net application. The file a user needs to download and that triggers installation is a \*.application file, and an MS Internet Information Server associates that with the mime type...

---

<div class="post-metadata">

**Author:** ![j.o.l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@j.o.l](https://www.ruby-forum.com/u/j.o.l)\
**Post date:** [March 9, 2016, 9:25pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/6 "2016-03-09T21:25:42Z")

</div>

after some more experiments it looks like I was caught by a looking at  
cached data. I was reloading the file for https as it was displayed as  
text  
(happens to be readable xml). However this reload was answered with  
not-modified without content-type (which is afaik standard conformant).  
Only on hard reload Chrome got a new copy with content type header.  
Goofish or not, maybe others stumble accross the same problem and this  
will  
help them to resolve the issue.

Posted at Nginx Forum:

> **[Re: Is there a length limitation on file extensions?](https://forum.nginx.org/read.php?2,265148,265200#msg-265200)**
>
> I am using Nginx to serve a website that hosts a .Net application. The file a user needs to download and that triggers installation is a \*.application file, and an MS Internet Information Server associates that with the mime type...

---

<div class="post-metadata">

**Author:** ![j.o.l](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@j.o.l](https://www.ruby-forum.com/u/j.o.l)\
**Post date:** [March 9, 2016, 9:26pm UTC](https://www.ruby-forum.com/t/is-there-a-length-limitation-on-file-extensions/244220/7 "2016-03-09T21:26:17Z")

</div>

j.o.l:

> Any other idea what to try or check?

I would write two separate server blocks,

server {  
listen 8080;

server\_name xxx;  
root /usr/local/nginx/conf/websites/xxx;  
autoindex on;  
types {  
application/x-ms-application application;  
}  
}

server {  
listen 443 ssl;  
ssl\_certificate /etc/letsencrypt/live/xxx/fullchain.pem;  
ssl\_certificate\_key /etc/letsencrypt/live/xxx/privkey.pem;

server\_name xxx;  
root /usr/local/nginx/conf/websites/xxx;  
autoindex on;  
types {  
application/x-ms-application application;  
}  
}
