0

I've looked at a couple similar question, but they didn't seem to be any help. I've got a vultr.com instance running a Wordpress in the default 1 click configuration. Centos6 if that matters. This is (and I would like it to remain) in the root (www.mysite.com). I would like to have my Django app running in www.mysite.com/crossfaded/. I don't want any downtime for my current server, so there is no domain name associated with the server yet. I'm trying to do this just using the IP.

The Wordpress site is working fine.

I've been following the guide here as then tried this one, but when I navigate to http://ip.add.re.ss/crossfaded/media/apple.jpg in my browser, I get a 404 from nginx. Going /crossfaded/media/ gives me a 403 from nginx and /crossfaded/invalidpath/ gives me a 404 served by Wordpress, so something is happening with the routing. I did chmod 777 apple.jpg on the off-chance it was a permissions issue, but that didn't do anything.

I have a hunch I've got the syntax of the location block muddled, but I'm really not sure.

wordpress_http.conf

upstream php-handler-http {
        server 127.0.0.1:9000;
        #server unix:/var/run/php5-fpm.sock;
}

server {
        listen 80 default_server;
        server_name _;
        #server_name wordpress.example.com;

        root /var/www/html/;
        index index.php;

        # set max upload size
        client_max_body_size 2G;
        fastcgi_buffers 64 4K;

        access_log /var/log/nginx/wordpress_http_access.log combined;
        error_log /var/log/nginx/wordpress_http_error.log;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

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

        location ^~ /wp-admin/ {
                auth_basic "Restricted";
                auth_basic_user_file /etc/nginx/htpasswd/wpadmin;

                location ~* \.(htaccess|htpasswd) {
                        deny all;
                }

                location ~ \.php(?:$|/) {
                        fastcgi_split_path_info ^(.+\.php)(/.+)$;
                        include fastcgi_params;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        fastcgi_param PATH_INFO $fastcgi_path_info;
                        fastcgi_pass php-handler-http;
                        fastcgi_read_timeout 60s;
                }
        }

        location ~* \.(htaccess|htpasswd) {
                deny all;
        }

        location ~ \.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_pass php-handler-http;
                fastcgi_read_timeout 60s;
        }

        # set long EXPIRES header on static assets
        location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                expires 30d;
                access_log off;
        }

location ~ /crossfaded/static/ {
            alias /root/crossfaded/static/;
    }

    location ~ /crossfaded/media/ {
        alias /root/crossfaded/media/ ;
    }
}

1 Answer 1

0

There were two problems:

  1. I needed a caret (^) in the location of the alias, so:

    location ^~ /crossfaded/static/ {
                alias /root/crossfaded/static/;
            }
    
    location ^~ /crossfaded/media/ {
            alias /root/crossfaded/media/ ;
          }
    
    1. The server defaulted ~/ to /root/. Nginx needs r-x permissions to all directories from / to the file in question. It did not have that. Moved the project directory to /home/.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.