For example, trying to call /wp-admin
results in 404, whereas /wp-admin/index.php
works flawlessly. I reckon this won’t play nice in the future.
I imagine this has something to do with a rewrite issue, but I don’t know nginx well enough to formulate a custom block to fix this. When I visit /home, it accurately shows me the homepage.
Here’s the nginx config for this vhost:
server {
root /var/www/[ip];
index index.php index.html index.htm index.nginx-debian.html;
server_name [ip] www.[ip];
client_max_body_size 50M;
location / {
proxy_set_header X_Forwarded_For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded_Proto $scheme;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# wordpress
location /home {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ /\.ht {
deny all;
}
}
Thanks in advance for any help with this :)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
I remedied this behaviour by moving the contents of my
wordpress
folder down into thewordpress/home
directory.My project structure used to be:
It is now:
Thanks to all who pointed me in the right direction / acted as my rubberduck.
Hi @Medallyon,
You need to add which files your Nginx should try to open first in your config. In the #wordpress block add the following:
Save the file, restart nginx and everything should work properly.
Regards, KFSys