我尝试连接的nginx和symfony 2。但是我的配置文件不适用于此框架。
server {
listen 80;
server_name test.com www.test.com;
access_log /var/log/nginx/test.access.log;
error_log /var/log/nginx/test.error.log;
location ~* '.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|docx|xlsx)$ {
root /home/test/var/www/test.com/public_html/web;
index index.html index.php;
access_log off;
expires 30d;
}
location ~ /'.ht {
deny all;
}
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_set_header Host $host;
proxy_connect_timeout 60;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_redirect off;
proxy_set_header Connection close;
proxy_pass_header Content-Type;
proxy_pass_header Content-Disposition;
proxy_pass_header Content-Length;
}
}
对于任何包含目录
的静态文件/home/test/var/www/test.com/public_html/web/css
or
/home/test/var/www/test.com/public_html/web/js
返回错误 403
我尝试使用这样的网址获取静态文件 test.com/css/style.css
我解决了这个问题。
我忘了添加用户www-data(nginx进程)到组测试(测试是所有者你家目录中的所有文件)。