سؤال

Here's my nginx configuration:-

user http;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    # main access log
    access_log  /var/log/nginx_access.log  main;

    # main error log
    error_log  /var/log/nginx_error.log debug;

    # My django main site
    server {
        listen   80;
        server_name mysite.com;
        # no security problem here, since / is alway passed to upstream
        root /var/git/mysite_live;
        # serve directly - analogous for static/staticfiles
        location /static {
            alias /var/git/mysite_live/public/static;
        }
        location /media {
            alias /var/git/mysite_live/public/media;
        }
        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_connect_timeout 10;
            proxy_read_timeout 10;
            proxy_pass http://localhost:8000/;
        }
        # what to serve if upstream is not available or crashes
        error_page 500 502 503 504 /media/50x.html;
    }

    # My wordpress blog, on a subdomain
    server {
        listen       80;                    # our server's public IP address:port
        server_name  blog.mysite.com;        # our domain name
        root         /srv/http/wordpress/;  # absolute path to your WordPress installation

        try_files $uri $uri/ /index.php;

        location ~ \.php$ {
            include        fastcgi_params;
            fastcgi_pass   localhost:9000;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }

    }

}

I have php-fpm installed and runnning rc.d start php-fpm on my arch linux server works fine.

Am I missing something that prevents nginx from using the php-fpm server - which should serve up my wordpress site located in /srv/http/wordpress in this reverse proxy set-up?

I am getting a 403 Forbidden error when I access blog.mysite.com and in my nginx error logs, the same errors are shown:

2012/03/03 05:09:30 [error] 26414#0: *7 directory index of "/srv/http/wordpress/" is forbidden, client: 133.235.39.138, server: blog.mysite.com, request: "GET / HTTP/1.1", host: "blog.mysite.com"  
هل كانت مفيدة؟

المحلول

Change:

    try_files $uri $uri/ /index.php;

To:

    try_files $uri /index.php;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top