우리는 먼저 proxy_pass에 대한 문서를 주의 깊게 그리고 완전히 읽어야 합니다 .
업스트림 서버로 전달되는 URI는 "proxy_pass"지시문이 URI와 함께 사용되는지 여부에 따라 결정됩니다. proxy_pass 지시문의 후행 슬래시는 URI가 있고과 같음을 의미합니다 /. 후행 슬래시가 없으면 모자 URI가 없음을 의미합니다.
URI가있는 Proxy_pass :
location /some_dir/ {
proxy_pass http://some_server/;
}
위의 경우 다음 프록시가 있습니다.
http:// your_server/some_dir/ some_subdir/some_file ->
http:// some_server/ some_subdir/some_file
기본적으로 요청 경로를에서 로 변경하려면 /some_dir/로 대체됩니다 .//some_dir/some_subdir/some_file/some_subdir/some_file
URI없는 Proxy_pass :
location /some_dir/ {
proxy_pass http://some_server;
}
두 번째 (후행 슬래시 없음) : 프록시는 다음과 같이됩니다.
http:// your_server /some_dir/some_subdir/some_file ->
http:// some_server /some_dir/some_subdir/some_file
기본적으로 전체 원래 요청 경로는 변경없이 전달됩니다.
따라서 귀하의 경우에는 원하는 것을 얻으려면 후행 슬래시를 드롭 해야하는 것 같습니다.
경고
자동 재 작성은 proxy_pass에서 변수를 사용하지 않는 경우에만 작동합니다. 변수를 사용하는 경우 직접 다시 작성해야합니다.
location /some_dir/ {
rewrite /some_dir/(.*) /$1 break;
proxy_pass $upstream_server;
}
재 작성이 작동하지 않는 다른 경우가 있기 때문에 문서를 읽는 것이 필수입니다.
편집하다
귀하의 질문을 다시 읽으면 html 출력을 편집하고 싶다는 것을 놓친 것 같습니다.
이를 위해 sub_filter 지시문을 사용할 수 있습니다 . 뭔가 ...
location /admin/ {
proxy_pass http://localhost:8080/;
sub_filter "http://your_server/" "http://your_server/admin/";
sub_filter_once off;
}
기본적으로 교체하려는 문자열과 교체 문자열