Welcome! Log In Create A New Profile

Advanced

Nginx ignoring root? Won't serve .zip files.

Posted by corrinox 
Nginx ignoring root? Won't serve .zip files.
November 23, 2012 12:02AM
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.

When I look at my error log I find that Nginx is looking for files in a location other than my route.

2012/11/23 13:50:50 [error] 14325#0: *774 open() "/usr/local/nginx/html/html/gamezip/G3zZ4pBq0BCeKb3o13EPKC4AaT63JvbnwOwQsV4p.zip" failed (2: No such file or directory), client: 121.140.215.179, server: static.ooparoopa.com, request: "GET /html/gamezip/G3zZ4pBq0BCeKb3o13EPKC4AaT63JvbnwOwQsV4p.zip HTTP/1.1", host: "static.ooparoopa.com"

Above is the entry from my error.log. Also here is my tcp.conf which is used to proxy websockets. Could this have anything to do with this not working?


tcp {

upstream socketio {
server 172.27.24.169:3000;
check interval=3000 rise=2 fall=5 timeout=1000;
}

server {
server_name _;
listen 3000;
timeout 43200000;
websocket_connect_timeout 43200000;
proxy_connect_timeout 43200000;
so_keepalive on;
tcp_nodelay on;
websocket_pass socketio;
websocket_buffer 1k;
#fair weight_mode=idle no_rr;
}
}

I have been scratching my head over this all morning I think there must be something simple that I have missed. Any help would be greatly appreciated. Thank you.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 80
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