Answer the question
In order to leave comments, you need to log in
Nginx in reverse proxy mode need a site to slide into?
We have several backs and now they decided to collect them under one domain name.
When shifting, location works partially, the problem is that it does not load styles, and it looks for styles from the root and not from the shift.
nginx
location config ~* ^/a/(.*)$ {
if ($http_cookie ~* ".+" ) {
set $do_not_cache 1;
}
proxy_cache_bypass $do_not_cache;
if ($request_method !~ ^(OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT|PROPFIND|PROPPATCH|MKCOL|COPY|MOVE|LOCK|UNLOCK|VERSION-CONTROL|REPORT|CHECKOUT|CHECKIN|UNCHECKOUT| MKWORKSPACE|UPDATE|LABEL|MERGE|BASELINE-CONTROL|MKACTIVITY|ORDERPATCH|ACL|SEARCH|MKCALENDAR|PATCH)$) {
return 405;
}
proxy_set_header Host $host
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection "";
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache cache;
proxy_cache_valid 1d;
proxy_cache_valid 404 502 503 1m;
rewrite ^/a/(.*)$ /$1 break;
proxy_http_version 1.1;
proxy_read_timeout 1800s;
proxy_send_timeout 1800s;
client_max_body_size 0;
proxy_buffering on;
proxy_request_buffering off;
proxy_redirect off;
proxy_pass 'back4 ';
That is, I shift it from the root to the /a/ directive, the site is loaded without styles, I look through the browser console, they are searched from the root and not from /a/
Help someone know how to fix this
Answer the question
In order to leave comments, you need to log in
It may be easier to make it in the form of several pages of the form www.asd.ry/y, www.asd.ry/z, and set up different locations for them with a different root
As already written in the comments, where the application decides to look for styles, and for good it is necessary to make the paths for loading statics customizable in each back.
However, if all the backs are on the same machine, you can substitute a crutch.
You can create a special location, even several, which will look for the requested file first in one folder, then in another, then in a third.
location ~* \.(css|js)$ {
root /path/to/back1;
try_files $uri @back2;
}
location @back2 {
root /path/to/back2;
try_files $uri @back3;
}
location @back3 {
root /path/to/back3;
try_files $uri =404;
}
location @back3 {
proxy_pass http://external-service.com;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question