如何为页面配置 Nginx refresh/reload

How to configure Nginx for page refresh/reload

我在后端服务器上部署了两个ear 文件。一个带有 web context-root '/',另一个带有 '/bli'。我正在使用 Nginx 将请求传递给后端服务器。 假设 xyz 是外部的 url,它通过 nginx 将请求传递给后端服务器。

这就是正在发生的事情- 1) https://xyz - 工作正常。页面 refresh/reload 也可以正常工作 2) https://xyz/bli - 重定向到 myserver.com/bli/ 并得到一个错误 3) https://xyz/bli/ - 工作正常但页面 refresh/reload 重定向到我的服务器。com/bli/

myserver.com 无法解析 URL 所以我得到一个错误

我尝试包含以下指令 -

location /bli/{
      proxy_pass https://backend;
      proxy_set_header Host myserver.com;
}

这解决了重定向到 myserver.com 的问题。但它反而重定向到 https://xyz:8011/bli/ which gives an error. It will work with https://xyz:443/bli/。不知道 8011 端口从哪里来 URL.

我也试过这个但是它重定向到 nginx 上的索引文件-

location /{
try_files $uri $uri/index.html
}

我试过了但是没用-

location /{
try_files $uri $uri/bli /bli
}

这是我的配置文件

server { 
listen *:8011;
root /apps/nginx/con/htdocs;
status_zone application_8011;

error_page 404 /error404.html;
error_page 500 502 503 504 /error500.html;

location /error404.html {
root /apps/nginx/con/htdocs/error_b;
}
location /error500.html {
root /apps/nginx/con/htdocs/error_b;
}
location / {

proxy_pass https://backend;
proxy_set_header Host myserver.com;

}
location /index.html {
root /apps/nginx/con/htdocs;
}

}

刷新https://xyz:/bli/ removes / at end and redirects to myserver.com/bli/ . Is there a way I can avoid removing / while refresh so that it refreshes https://xyz:/bli/。或者我需要在我的配置文件中包含什么来解决页面刷新问题。

以下解决方案对我有用 -

location /{
      proxy_pass https://backend;
      proxy_set_header Host myserver.com;
      port_in_redirect off
}

location /bli/{
          proxy_pass https://backend/bli/;
          proxy_set_header Host myserver.com;
          port_in_redirect off
}