I am converting a site over from WHM/Cpanel to running LEMP. After learning a lot about NGINX I am feeling pretty confident but I have one minor persistent issue I can't seem to figure out.
My featured images all have the wrong path. They show /mnt/www/website//wp-content/uploads/image-here.jpg. This appears to be an issue with relative urls. If I view the images in the post backend it shows up fine, it, just fails on the frontend.
Am I missing something silly? Thanks in advance.
nginx.conf
user nginx;
# You can increase this up to the # of CPU cores ####
worker_processes 1;
#error_log /mnt/www/website/error.log warn;
events { worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
access_log off;
sendfile on;
tcp_nodelay on;
tcp_nopush on;
client_max_body_size 2M;
keepalive_timeout 10;
include /usr/local/nginx/vhosts/*;
gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xm$
}
wordpress.conf
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar$
access_log off; log_not_found off; expires max;
}
# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this server, which is entirel$
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And t$
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_intercept_errors on;
# fastcgi_pass php;
fastcgi_pass unix:/var/run/php-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
}
restrictions.conf
# Common root location
location / {
# This try_files directive is used to enable pretty, SEO-friendly URLs
# and permalinks for Wordpress. Leave it *off* to start with, and then
# turn it on once you've gotten Wordpress configured!
try_files $uri $uri/ /index.php?$args;
}
# This location pevents any requests for the Wordpress admin interface
# from being accepted if those requests don't come from your LAN. This
# is optional but recommended.
# location ~* wp-admin {
# try_files $uri $uri/ =404;
# allow 192.168.1.0/24;
# allow 127.0.0.1;
allow XXXXXXXXXX;
# deny all;
# }
# Show "Not Found" 404 errors in place of "Forbidden" 403 errors, because
# forbidden errors allow attackers potential insight into your server's
# layout and contents
error_page 403 =404;
# Prevent access to any files starting with a dot, like .htaccess
# or text editor temp files
location ~ /\. { access_log off; log_not_found off; deny all; }
# Prevent access to any files starting with a $ (usually temp files)
location ~ ~$ { access_log off; log_not_found off; deny all; }
# Do not log access to robots.txt, to keep the logs cleaner
location = /robots.txt { access_log off; log_not_found off; }
# Do not log access to the favicon, to keep the logs cleaner
location = /favicon.ico { access_log off; log_not_found off; }
# Keep images and CSS around in browser cache for as long as possible,
# to cut down on server load
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
# Common deny or internal locations, to help prevent access to areas of
# the site that should not be public
location ~* wp-admin/includes { deny all; }
location ~* wp-includes/theme-compat/ { deny all; }
location ~* wp-includes/js/tinymce/langs/.*\.php { deny all; }
location /wp-content/ { internal; }
location /wp-includes/ { internal; }
# The next line protects the wp-config.php file from being accessed, but
# we need to be able to run the file for the initial site setup. Uncomment
# the next line after setup is completed and reload Nginx.
location ~* wp-config.php { deny all; }
# Prevent any potentially-executable files in the uploads directory from
# being executed by forcing their MIME type to text/plain
location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php)$ {
types { }
default_type text/plain;
}
# Add trailing slash to */wp-admin requests so the admin interface
# works correctly
rewrite /wp-admin$ $scheme://$host$uri/ permanent;