admin管理员组文章数量:1389749
I have an website running in https://localhost:7443/__admin. I have nginx running in the same host in https://localhost:8443.
I want the users to launch the webapp with the url https://localhost:8443/wiremock so that it redirects to https://localhost:7443/__admin. I used the below nginx conf to redirect. When I launch the app in chrome, the first call to the webapp is successful but the subsequent calls are returning 404. The subsequent calls are not requested by the user, its internally made based on the webapp.
When I looked at the chrome console, what I noticed is the subsequent calls(the referred calls) are redirected to https://localhost:8443/__admin instead of https://localhost:8443/wiremock/__admin. Appreciate if someone can help what is missing in my config.
server {
listen 8443 ssl;
server_name localhost;
access_log /dev/stdout;
error_log /dev/stderr;
ssl_certificate /etc/ssl/certs/self-signed-cert-for-instance.crt;
ssl_certificate_key /etc/ssl/private/self-signed-cert-for-instance.key;
location /wiremock/__admin {
rewrite ^/wiremock(.*)$ $1 break;
proxy_pass https://localhost:7443/__admin;
proxy_set_header Host $host;
}
}
I have an website running in https://localhost:7443/__admin. I have nginx running in the same host in https://localhost:8443.
I want the users to launch the webapp with the url https://localhost:8443/wiremock so that it redirects to https://localhost:7443/__admin. I used the below nginx conf to redirect. When I launch the app in chrome, the first call to the webapp is successful but the subsequent calls are returning 404. The subsequent calls are not requested by the user, its internally made based on the webapp.
When I looked at the chrome console, what I noticed is the subsequent calls(the referred calls) are redirected to https://localhost:8443/__admin instead of https://localhost:8443/wiremock/__admin. Appreciate if someone can help what is missing in my config.
server {
listen 8443 ssl;
server_name localhost;
access_log /dev/stdout;
error_log /dev/stderr;
ssl_certificate /etc/ssl/certs/self-signed-cert-for-instance.crt;
ssl_certificate_key /etc/ssl/private/self-signed-cert-for-instance.key;
location /wiremock/__admin {
rewrite ^/wiremock(.*)$ $1 break;
proxy_pass https://localhost:7443/__admin;
proxy_set_header Host $host;
}
}
Share Improve this question asked Mar 13 at 6:43 Rohit12Rohit12 531 silver badge6 bronze badges 2 |1 Answer
Reset to default -1Are you requesting subsequent resource loading in the backend?
If so, try specifying sub_filter
example
location /wiremock/__admin {
rewrite ^/wiremock(.*)$ $1 break;
proxy_pass https://localhost:7443/__admin;
proxy_set_header Host $host;
sub_filter '/__admin' '/wiremock/__admin';
sub_filter_once off;
proxy_set_header Accept-Encoding "";
}
sub_filter
will replace all response bodies from the backend, so be careful not to make unintended matches.
http://nginx./en/docs/http/ngx_http_sub_module.html
I think the best way to fix it is to specify resource loading that matches the front.
本文标签: Nginx reverse proxy setup for redirectsStack Overflow
版权声明:本文标题:Nginx reverse proxy setup for redirects - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744716651a2621443.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
sub_filter
approach suggested in the answer to your question is definitely one of them. – Ivan Shatsky Commented Mar 14 at 13:51