Answer the question
In order to leave comments, you need to log in
Nginx rewrite user-agent?
I have a web application with an angular frontend and a java backend. There is some service in BU, for example "test".
It is necessary to check the user-agent when requesting the page myapp.com/somepage and if it is a search robot, for example yandexbot, then give it the page myapp.com/test/somepage, otherwise give the angular application at myapp.com/somepage. How to implement correctly?
current nginx config is something like this:
server {
server_name myapp.com;
listen 80;
charset utf-8;
default_type "text/html";
location /test
{
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/proxy.conf;
}
location /
{
root /var/www/myapp/dist/;
error_page 405 = $uri;
try_files $uri/ $uri /index.html;
}
}
Answer the question
In order to leave comments, you need to log in
It is necessary to organize a check by user-agent and give the necessary content according to the condition. To do this, you need to make the condition
https://nginx.ru/ru/docs/http/ngx_http_rewrite_mod...
There, right in the examples, there is a condition with a user agent)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question