Welcome! Log In Create A New Profile

Advanced

How to serve static files with no extension as text/html instead of Content-Type: application/octet-stream

Posted by vbod 
How could I serve all static files that start with "somestring-" and have no file extension as text/html?
Nginx serves them by default as a bin file sending a header Content-Type: application/octet-stream. Browser will offer the file for download instead of rendering the HTML. Please help my server is getting hammered. My current config goes like this:

server {
server_name site1;
root /var/html/site1/static;
index index.html index.htm;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
client_max_body_size 10M;
location / {
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (!-f $request_filename) {
proxy_pass http://apache;
break;
}
}
}



Edited 2 time(s). Last edit at 05/27/2011 06:32AM by vbod.
All sorted, just changed the default type to
default_type text/html;
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready