<div dir="ltr"><font color="#000000">Did you tried to only hide the header with</font><div><font color="#000000"><span style="font-family:arial,sans-serif;font-size:13px">proxy_hide_header Content-Type;</span><br></font></div>

<div><span style="font-family:arial,sans-serif;font-size:13px"><font color="#000000">and let nginx use the mime.types to set the content type?</font></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><font color="#000000"><br>

</font></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><font color="#000000">Do not set the add_header Content-Type manually.</font></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><font color="#000000"><br>

</font></span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><font color="#000000">Let me know the result.</font></span></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 7, 2014 at 12:57 PM, manish-ezest <span dir="ltr"><<a href="mailto:nginx-forum@nginx.us" target="_blank">nginx-forum@nginx.us</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello wandenberg,<br>
<br>
Thank you for your response. I truly appreciate your help. I tried this<br>
options given below<br>
<br>
######First Method###############<br>
1. Edit nginx.conf and add<br>
<div class="">    map $uri $custom_content_type {<br>
        default "text/html";<br>
        ~(.*\.json)$ "application/json";<br>
    }<br>
<br>
</div>2. Put the custom map in location directive<br>
location / {<br>
        proxy_redirect     off;<br>
        proxy_set_header   Host             <a href="http://www-aaa.com.s3.amazonaws.com" target="_blank">www-aaa.com.s3.amazonaws.com</a>;<br>
        proxy_set_header   X-Real-IP        $remote_addr;<br>
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;<br>
        proxy_set_header   Referer          <a href="http://www-aaa.com" target="_blank">www-aaa.com</a>;<br>
        proxy_pass         <a href="http://www-aaa.com.s3.amazonaws.com/" target="_blank">http://www-aaa.com.s3.amazonaws.com/</a>;<br>
        add_header         Pragma "no-cache";<br>
        proxy_cache_valid  200 302  10m;<br>
        proxy_read_timeout 60s;<br>
<div class="">        proxy_hide_header Content-Type;<br>
        add_header Content-Type $custom_content_type;<br>
}<br>
<br>
</div>######Second Method###############<br>
1. Edit nginx.conf and add<br>
<div class="">    map $uri $custom_content_type {<br>
        default "text/html";<br>
        ~(.*\.json)$ "application/json";<br>
    }<br>
<br>
</div>2. Put the custom map in location directive<br>
location / {<br>
        proxy_redirect     off;<br>
        proxy_set_header   Host             <a href="http://www-aaa.com.s3.amazonaws.com" target="_blank">www-aaa.com.s3.amazonaws.com</a>;<br>
        proxy_set_header   X-Real-IP        $remote_addr;<br>
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;<br>
        proxy_set_header   Referer          <a href="http://www-aaa.com" target="_blank">www-aaa.com</a>;<br>
        proxy_pass         <a href="http://www-aaa.com.s3.amazonaws.com/" target="_blank">http://www-aaa.com.s3.amazonaws.com/</a>;<br>
        add_header         Pragma "no-cache";<br>
        proxy_cache_valid  200 302  10m;<br>
        proxy_read_timeout 60s;<br>
<div class="">        location ~ \.json$ {<br>
                  proxy_hide_header Content-Type;<br>
                  add_header Content-Type $custom_content_type;<br>
        }<br>
}<br>
<br>
</div>##Third Method####################<br>
<br>
1. Enter this in server block of nginx.<br>
        location ~ \.json$ {<br>
               types { }<br>
               default_type  application/json;<br>
        }<br>
<br>
#################################<br>
<br>
1. When I tried first method I put below content in "location / { }" and due<br>
to this the JSON file served as application/json but all other files loaded<br>
as text/html as it was default in the map directive which caused image/css<br>
to not load. I thought it would read the mime.types files and will select<br>
the appropriate Content-Type.<br>
#########################<br>
<div class="">proxy_hide_header Content-Type;<br>
add_header Content-Type $custom_content_type;<br>
</div>##########################<br>
<br>
2. When I tried second and third method, I am getting 404 because it is<br>
taking docroot as /var/empty<br>
<br>
2014/08/07 17:13:22 [error] 14205#0: *33 open()<br>
"/var/empty/aaa/bbb/ccc/ddd/eee.json" failed (2: No such file or directory),<br>
client: 5.5.5.5., server: <a href="http://www-aaa.com" target="_blank">www-aaa.com</a>, request: "GET<br>
/aaa/bbb/ccc/ddd/eee.json HTTP/1.1", host: "www.aaa.coml"<br>
<br>
So my question is where should I put the location ~\.json block(in location<br>
/ {} or in server directive)?<br>
<br>
**************my NGINX.conf********************<br>
user              nginx;<br>
worker_processes  1;<br>
error_log         /var/log/nginx/error.log  notice;<br>
pid               /var/run/nginx.pid;<br>
worker_rlimit_nofile 30000;<br>
events {<br>
    worker_connections  1024;<br>
}<br>
http {<br>
    include       /etc/nginx/mime.types;<br>
    default_type  application/octet-stream;<br>
<br>
    log_format  main  '$remote_addr - $remote_user [$time_local] $request '<br>
                      '"$status" $body_bytes_sent "$http_referer" '<br>
                      '"$http_user_agent" "$http_x_forwarded_for"';<br>
    log_format combined_time '$remote_addr - $remote_user [$time_local]'<br>
                    '"$request" $status $body_bytes_sent '<br>
                    '"$http_referer" "$http_user_agent" $request_time';<br>
<br>
    access_log  /var/log/nginx/access.log  combined_time;<br>
        include /etc/nginx/servers/*.conf;<br>
}<br>
**********************************************<br>
<br>
******************************VHOST SETTING*****<br>
server {<br>
        listen       80;<br>
        server_name  <a href="http://www-aaa.com" target="_blank">www-aaa.com</a>;<br>
        add_header  Cache-Control off;<br>
        expires     1d;<br>
        root        /var/empty;<br>
        error_log         /var/log/nginx/www.aaa.com-error.log;<br>
        access_log        /var/log/nginx/www.aaa.com-access.log<br>
combined_time;<br>
        location = /favicon.ico {<br>
                root /www;<br>
        }<br>
proxy_intercept_errors on;<br>
error_page 400 401 402 403 404 406 407 408 409 410 411 412 413 414 415 416<br>
417 495 496 497 500 501 502 503 504 505 506 507 = /<a href="http://error_page.pl" target="_blank">error_page.pl</a>;<br>
error_page 405 =200 $uri;<br>
location /<a href="http://error_page.pl" target="_blank">error_page.pl</a> {<br>
        fastcgi_pass                    <a href="http://127.0.0.1:8999" target="_blank">127.0.0.1:8999</a>;<br>
        fastcgi_param REQUEST_URI       $request_uri;<br>
        fastcgi_pass_header             "Status";<br>
}<br>
<br>
location / {<br>
        proxy_redirect     off;<br>
        proxy_set_header   Host             <a href="http://www.aaa.com.s3.amazonaws.com" target="_blank">www.aaa.com.s3.amazonaws.com</a>;<br>
        proxy_set_header   X-Real-IP        $remote_addr;<br>
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;<br>
        proxy_set_header   Referer          <a href="http://www.aaa.com" target="_blank">www.aaa.com</a>;<br>
        proxy_pass         <a href="http://www.aaa.com.s3.amazonaws.com/" target="_blank">http://www.aaa.com.s3.amazonaws.com/</a>;<br>
}<br>
}<br>
***************************************************************************<br>
<br>
NOTE: All my files are served from s3 bucket and not a single files are in<br>
the server.<br>
<br>
--Manish<br>
<br>
Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,239473,252390#msg-252390" target="_blank">http://forum.nginx.org/read.php?2,239473,252390#msg-252390</a><br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div></div>