0

I'm pulling out my hair on this one.

You can see yourself here - http://starterpad.com/blog/ - that all the images, CSS, and JS files are 404 errors.

The main StarterPad site (http://starterpad.com) is running Rails, and it seems fine. But the /blog is WordPress and it has seen better days.

Here's our nginx.conf file:

user  apache;
worker_processes  2;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}



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


    passenger_root /usr/local/rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.24;
    passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p247/ruby;


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

    access_log  /var/log/nginx/access.log  main;

    sendfile       on;
    tcp_nopush     on;
    reset_timedout_connection on;

    keepalive_timeout  65;

    gzip  on;

#    include /etc/nginx/conf.d/*.conf;


server {
  server_name www.starterpad.com;
  return 301 $scheme://starterpad.com$request_uri;
}


  upstream starterpad {
    server unix:///var/www/starterpad.com/shared/tmp/sockets/puma.sock fail_timeout=0;
  }

  server {
    listen 80;
    server_name starterpad.com vps.starterpad.com;
    root /var/www/starterpad.com/current/public; 
    error_log /var/www/starterpad.com/shared/log/nginx_error.log;
    access_log off;

    error_page 403 404          /404.html;
    error_page 422              /422.html;
    error_page 500 502 503 504  /500.html;

    location ^~ /assets|uploads/ {
        gzip_static on;
        expires max;
        add_header Cache-Control public;
    }

    location @starterpad {
        proxy_pass http://starterpad; # match the name of upstream directive which is defined above
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location / {
        try_files /index.html $uri.html $uri @starterpad;
    }

    location /blog/ {
        #try_files $uri $uri/ /blog/index.php?$args;
        #deny all;      
        root /var/www/starterpad.com/blog;       
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        include wpsecure.conf;
        index index.php;
        try_files $uri $uri/ /index.php?q=$uri&$args;        
    }
    location ~ \.php {
        root /var/www/starterpad.com/blog;
        try_files $uri = 404;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }    
  }
}

Here's some errors from the error log, but they don't seem helpful to me:

2015/01/26 22:16:06 [error] 11511#0: *11 open() "/var/www/starterpad.com/blog/blog/wp-content/themes/sparkling/inc/css/font-awesome.min.css" failed (2: No such file or directory), client: 173.245.48.128, server: starterpad.com, request: "GET /blog/wp-content/themes/sparkling/inc/css/font-awesome.min.css?ver=4.1 HTTP/1.1", host: "starterpad.com", referrer: "http://starterpad.com/blog/"

2015/01/26 19:22:26 [error] 10431#0: *28798 FastCGI sent in stderr: "Unable to open primary script: /var/www/starterpad.com/blog/b6d767d2f8ed5d21a44b0e5886680cb9/generator.php (No such file or directory)" while reading response header from upstream, client: 108.162.215.123, server: starterpad.com, request: "POST /b6d767d2f8ed5d21a44b0e5886680cb9/generator.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "starterpad.com", referrer: "http://starterpad.com/blog/wp-content/uploads/2014/12/SoftwareProgrammer-750x410.jpg"

I've read so many Stack Overflow and other pages, tried almost everything in the nginx.conf, but for the life of me I can't get it to work.

Any ideas? You'd be my frickin' hero!

  • Look at your error log. – Michael Hampton Jan 27 '15 at 2:06
  • nginx error log has nothing useful. Is there another error log I should be looking at? – Kane Jan 27 '15 at 2:09
  • I posted a couple possibly-useful error messages above – Kane Jan 27 '15 at 2:21
  • 1
    Yes, the first error makes it blatantly obvious what's going on. – Michael Hampton Jan 27 '15 at 2:38
  • Oh duh! Double /blog lol – Kane Jan 27 '15 at 3:25
1

Figured it out (thanks to MichaelHampton). The changed rows are in bold below.


location /blog/ {
root /var/www/starterpad.com;
include wpsecure.conf;
index index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ .php$ {
root /var/www/starterpad.com/blog;
try_files $uri $uri/ /index.php?q=$uri&$args;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.