Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I converted a few sites from Apache to nginx and it was running well for a while. I recently updated the nginx configuration regarding the new changes to W3 Total Cache rules. I also tried to clean up my config.

I am having really odd issues. One or two sites on this server will give me a 404 error and not load until. I verified the sites-available configuration file is exactly like the other sites. Most of the sites work fine, and as I was editing the WordPress sections of the conf, I noticed some sites would do this or 403 error but not all sites. I find this really confusing as if there is a problem with the config, it should be all sites. I went through the files for the sites that have the problems over and over and I can't see any typos or variance from the other sites. If I disable W3TC completely, everything works fine. One site I had a lot of problems with, the only way to fix it was to delete all traces of W3TC manually, and reinstall it.

This is my configuration file, it is all one file here, but it is split up in multiple files on the server (drop.conf, wordpress.conf, php.conf), I just pasted them all into one file.

server {
listen       8080;
server_name  domain.com www.domain.com;
root         /srv/www/domain.com/public;
access_log   /srv/www/domain.com/log/access.log;
error_log    /srv/www/domain.com/log/error.log;

location = /robots.txt  { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }  
location ~ /\.          { access_log off; log_not_found off; deny all; }
location ~ ~$           { access_log off; log_not_found off; deny all; }    

location / { 
        index index.html index.php;
        try_files $uri $uri/ /index.php?$args; 
}

location /search {
        limit_req zone=wpsearch burst=3 nodelay;
        try_files $uri /index.php;
}

location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

# Prohibit php files from executing in wp-uploads
location ~* ^/wp-content/uploads/.*.php$ {
        return 403;
}

location ~ /nginx.conf { deny all; }    

        include /srv/www/domain.com/public/nginx.conf;    

location ~ \.php {
        fastcgi_intercept_errors off;
        client_max_body_size 25M;
        try_files      $uri =404;
        limit_conn phplimit 5;
        fastcgi_index  index.php;

        fastcgi_param   QUERY_STRING            $query_string;
        fastcgi_param   REQUEST_METHOD          $request_method;
        fastcgi_param   CONTENT_TYPE            $content_type;
        fastcgi_param   CONTENT_LENGTH          $content_length;

        fastcgi_param   SCRIPT_FILENAME         $request_filename;
        fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
        fastcgi_param   REQUEST_URI             $request_uri;
        fastcgi_param   DOCUMENT_URI            $document_uri;
        fastcgi_param   DOCUMENT_ROOT           $document_root;
        fastcgi_param   SERVER_PROTOCOL         $server_protocol;

        fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
        fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

        fastcgi_param   REMOTE_ADDR             $remote_addr;
        fastcgi_param   REMOTE_PORT             $remote_port;
        fastcgi_param   SERVER_ADDR             $server_addr;
        fastcgi_param   SERVER_PORT             $server_port;
        fastcgi_param   SERVER_NAME             $server_name;

        fastcgi_param   HTTPS                   $https;

        # PHP only, required if PHP was built with --enable-force-cgi-redirect
        fastcgi_param   REDIRECT_STATUS         200;

        fastcgi_pass   unix:/var/run/php5-fpm.sock;
}
}
share|improve this question

closed as off-topic by Mark Kaplun, G. M., bungeshea_, ialocin, Johannes Pille Aug 22 at 10:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, G. M., bungeshea_, ialocin, Johannes Pille
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Try including /srv/www/domain.com/public/nginx.conf on top of all other location blocks! –  Pothi Apr 9 '13 at 4:11