location / {
resolver 127.0.0.1;
if ($http_x_requested_with = XMLHttpRequest) {
set $pass1 http://www.site.ru/;
}
if ($http_x_requested_with != XMLHttpRequest) {
set $pass1 http://www.site.ru/user/1/;
}
proxy_pass $pass1;
}
resolver 127.0.0.1;
location / {
proxy_pass http://www.site.ru/user/1/;
}
location /ajax/ {
proxy_pass http://www.site.ru/ajax/
}
server{
...
if ($http_x_requested_with = XMLHttpRequest) {
rewrite ^(.*)$ /ajax/$1 last;
}
location / {
if ($http_x_requested_with = XMLHttpRequest) {
rewrite ^(.*)$ /ajax/$1 break;
}
}
commented on October 3rd 19 at 02:55map $http_x_requested_with $passvar {
default http://www.site.ru/user/1/;
XMLHttpRequest http://www.site.ru/;
}
resolver 127.0.0.1;
server {
location / {
proxy_pass $passvar;
}
}
Find more questions by tags Nginx
Unfortunately, it is not suitable, because of the 3 only 1 of the programmers were not lazy and all Ajax-requests via post /ajax, the rest of the titles are hit and miss, something in the spirit site.ru/blogs/create/blogName.
Because using location I can wrap approximately only a third of the queries. That and trying to write a check for everything Ajax. - Ericka_Hegmann55 commented on October 3rd 19 at 02:47