Nginx .zip files return 404
- by Kenley Tomlin
I have set up Nginx as a reverse proxy for Node and to serve my static files and user uploaded images.
Everything is working beautifully except that I can't understand why Nginx can't find my .zip files. Here is my nginx.conf.
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
proxy_cache_path /var/www/web_cache levels=1:2 keys_zone=ooparoopaweb_cache:8m max_size=1000m inactive=600m;
sendfile on;
upstream *******_node {
server 172.27.198.66:8888 max_fails=3 fail_timeout=20s;
#fair weight_mode=idle no_rr
}
upstream ******_json_node {
server 172.27.176.57:3300 max_fails=3 fail_timeout=20s;
}
server { #REDIRECT ALL HTTP REQUESTS FOR FRONT-END SITE TO HTTPS
listen 80;
server_name *******.com www.******.com;
return 301 https://$host$request_uri;
}
server { #MOBILE APPLICATION PROXY TO NODE JSON
listen 3300 ssl;
ssl_certificate /*****/*******/json_ssl/server.crt;
ssl_certificate_key /*****/******/json_ssl/server.key;
server_name json.*******.com;
location / {
proxy_pass http://******_json_node;
proxy_redirect off;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
proxy_set_header X-Forwarded-Proto https;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffers 32 4k;
}
}
server { #******.COM FRONT-END SITE PROXY TO NODE WEB SERVER
listen 443 ssl;
ssl_certificate /***/***/web_ssl/********.crt;
ssl_certificate_key /****/*****/web_ssl/myserver.key;
server_name mydomain.com www.mydomain.com;
add_header Strict-Transport-Security max-age=500;
location / {
gzip on;
gzip_types text/html text/css application/json application/x-javascript;
proxy_pass http://mydomain_node;
proxy_redirect off;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
proxy_set_header X-Forwarded-Proto https;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffers 32 4k;
}
}
server { #ADMIN SITE PROXY TO NODE BACK-END
listen 80;
server_name admin.mydomain.com;
location / {
proxy_pass http://mydomain_node;
proxy_redirect off;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_connect_timeout 90s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffers 32 4k;
}
}
server { # SERVES STATIC FILES
listen 80;
listen 443 ssl;
ssl_certificate /**/*****/server.crt;
ssl_certificate_key /****/******/server.key;
server_name static.domain.com;
access_log static.domain.access.log;
root /var/www/mystatic/;
location ~*\.(jpeg|jpg|png|ico)$ {
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml
application/xml application/rss+xml text/javascript image/svg+xml
application/vnd.ms-fontobject application/x-font-ttf font/opentype image/png image/jpeg
application/zip;
expires 10d;
add_header Cache-Control public;
}
location ~*\.zip {
#internal;
add_header Content-Type "application/zip";
add_header Content-Disposition "attachment; filename=gamezip.zip";
}
}
}
include tcp.conf;
Tcp.conf contains settings that allow Nginx to proxy websockets. I don't believe anything contained within it is relevant to this question. I also want to add that I want the zip files to be a forced download.