Answer the question
In order to leave comments, you need to log in
How to properly proxy 404 wordpress error?
Good afternoon, there is not a trivial task.
We have: nginx + php-fpm. wordpress.
Task: When accessing a domain at .ru/username/, you need to proxy the request to another server. Unfortunately, it is impossible to distinguish a username from a simple page, there are no prefixes.
What came to mind is to send all 404 errors to an external server. But how to implement it correctly when all requests are processed by index.php...
location / {
try_files $uri $uri/ /index.php?$args;
}
error_page 404 = @profiles;
location ~ .php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_intercept_errors on; # For profiles
}
location @profiles {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://...:8080;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question