我的 nginx 中有这个配置,我仍然得到 OP 的结果。
还有什么需要考虑的吗? 我只是告诉浏览器正确缓存静态文件? Nginx 没有缓存它,这是我的假设,但是一旦我把那个位置指令放在这个里面,我就会得到所有匹配的错误。它似乎在服务器上本地查找文件。但是我删除了它并且它工作正常并从代理服务器提供它。
错误:
"/etc/nginx/html/static/js/scripts.js" failed (2: No such file or directory)
配置:
worker_processes auto;
worker_rlimit_nofile 8192;
events {
worker_connections 4096; ## Default: 1024
}
http {
include /etc/nginx/mime.types;
include /etc/nginx/proxy.conf;
index index.html;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# access_log logs/access.log main;
sendfile on;
tcp_nopush on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name domaincom;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/key.pem;
keepalive_timeout 70;
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1M;
# access_log off;
add_header Cache-Control "public";
add_header Vary Accept-Encoding;
}
# pass requests for dynamic content to rails/turbogears/zope, et al
location / {
proxy_pass http://ssapp:5000;
}
}
}