Answer the question
In order to leave comments, you need to log in
nginx. Proxy requests from sub.domain.com to domain.com/sub/. Why does the client's url sometimes get rewritten?
Working config.
server {
listen 80;
server_name ~^(?:www\.)?(?:(?<sd>.*)\.)?domain\.com$;
location / {
proxy_pass http://localhost:80/$sd$request_uri;
proxy_set_header Host domain.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache off;
proxy_redirect off;
break;
}
}
Answer the question
In order to leave comments, you need to log in
It seems to me that your application does the redirect, not Nginx. Because return status: 301 Moved Permanently.
What is used on the backend?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question