T
T
Timur Kalimullin2018-10-19 18:55:15
Nginx
Timur Kalimullin, 2018-10-19 18:55:15

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;
}

as a result, instead of the desired /username/ on the external server, we get index.php, which is obvious.
Any ideas how to do this in the current implementation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Kalimullin, 2018-10-19
@ZetRider

I did it, it works
proxy_pass http://...:8080$request_uri;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question