403 forbidden on wordpress index with nginx, the rest of the pages work fine -


i'm setting blog on new ec2 instance because 1 of sites on server that's hosting being ddosed. i'm having trouble nginx, because can either see pages fine 403 on index, or see index 404 on pages (depending on config i'm using)

here's nginx config:

server {     listen       80;      server_name  www.test.com;     server_name  test.com;     root /www/blog;      include conf.d/wordpress/simple.conf; } 

and simple.conf:

location = /favicon.ico {             log_not_found off;             access_log off;     }      location = /robots.txt {             allow all;             log_not_found off;             access_log off;     }      location / {             # cool because no php touched static content.              # include "?$args" part non-default permalinks doesn't break when using query string             try_files $uri $uri/ /index.php?$args;     }      location ~ \.php$ {             #note: should have "cgi.fix_pathinfo = 0;" in php.ini             include fastcgi.conf;             fastcgi_intercept_errors on;             fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;     }      location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {             expires max;             log_not_found off;     } 

if change try_files $uri $uri/ /index.php?$args; index index.php, front page work fine , rest 404. if leave that, front page 403.

here's error log:

2013/08/07 19:19:41 [error] 25333#0: *1 directory index of "/www/blog/" forbidden, client: 64.129.x.x, server: test.com, request: "get / http/1.1", host: "www.test.com" 

that directory 755 on nginx user:

drwxr-xr-x 6 nginx nginx  4096 aug  7 18:42 blog 

is there obvious i'm doing wrong ?

thanks !

add index index.php; in server block, if doesn't work need remove $uri/ because don't want autoindex on


edit: noticed figured out problem, i'll add reasoning behind it, reason why needed autoindex on; because without nginx follow try_files rules,

  1. check if there's file called /, , of course fails.
  2. check if there's directory called / (by adding root = /www/blog/), check succeed, tries list content of folder.
  3. since didn't specify autoindex on; default nginx should forbid directory listing, return 403 forbidden error.
  4. the rest of site works fine because fails $uri/ test or doesn't reach it, because don't have folder called image.jpg or stylesheet.css etc.

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -