frappe_docker icon indicating copy to clipboard operation
frappe_docker copied to clipboard

How to fix trailing slashes causing a https url to redirect to http

Open insatiable-foo opened this issue 1 year ago • 2 comments

I am following the steps in custom-app.md to host our custom apps

When a trailing slash is added to a https url it is getting redirected to a http url with a port name appended to the domain name which causes a broken page

For example when a user visits https://oursubdomain.ourdomain.com/app/home it works But when a user visits https://oursubdomain.ourdomain.com/app/home/ [note the trailing slash] it is getting redirected to http://oursubdomain.ourdomain.com:8080/app/home [note no https and 8080 is getting appended]

Please help me to fix the issue

insatiable-foo avatar Jan 06 '24 03:01 insatiable-foo

Issue related to Ingress Nginx: https://github.com/kubernetes/ingress-nginx/issues/5997

revant avatar Jan 09 '24 12:01 revant

Fixed by making changes to resources/nginx-template.conf

I changed this

          rewrite ^(.+)/$ $1 permanent;
          rewrite ^(.+)/index\.html$ $1 permanent;
          rewrite ^(.+)\.html$ $1 permanent;

to

        rewrite ^(.+)/$ "https://$host$1" permanent;
        rewrite ^(.+)/index\.html$ "https://$host$1" permanent;
        rewrite ^(.+)\.html$ "https://$host$1" permanent;

don't know if it is a correct solution.

there is one more issue due to the old redirect configuration, early users who visited the site with a trailing / like https://<host><uri>/ were redirected to http://<host><uri>:8080 as it is a permanent redirect chrome has cached it

because of this now when those users visit a url they previously visted that contain a trailing /. chrome uses the cache and they end up with the http url with port

The users have to clear the browser cache manually to fix this

It will be helpful if some one provides a better solution to clear the redirect cache without user involvement

insatiable-foo avatar Feb 07 '24 06:02 insatiable-foo

This issue has been automatically marked as stale. You have a week to explain why you believe this is an error.

github-actions[bot] avatar Apr 08 '24 00:04 github-actions[bot]