jsonnet-libs icon indicating copy to clipboard operation
jsonnet-libs copied to clipboard

nginx-directory: preserve url encoded chars

Open darrenjaneczek opened this issue 4 years ago • 10 comments

It was discovered that encoded characters such as %20 were converted through the proxy engine, resulting in 400 "bad request." This would affect urls such as: e.g., baseurl.com/server_name/resource%20with%20space

The previous solution uses a regex location selector, and with that approach the $2 group variable would decode the url, causing the 400 if there were any special %-encoded characters. The example above, resulted in: baseurl.com/server_name/resource with space

After replacing to a non-regex location selector, some additional efforts were required to ensure:

  • relative urls work within the proxy subdir
  • redirects from the target server are translated correctly
  • %-encoded characters proxy without 400 "bad request"

darrenjaneczek avatar Jul 26 '21 04:07 darrenjaneczek

Not ready for merge. Will work in this further in a few weeks.

Required outstanding fixes:

  • [ ] Handle paths that end in /, e.g., path: 'endwithslash/',
  • [ ] Handle requests to legitimate "path" entries, which end in //, e.g., https://site.net/test// where path: 'test'
  • [ ] Note potential environment setup errors if there are invalid entries in the configuration; see:
    • https://github.com/grafana/deployment_tools/pull/13996
    • https://github.com/grafana/deployment_tools/pull/13998
      $ kubectl -n default logs nginx-6bc87ddb99-74qd2 
      2021/07/30 13:59:12 [emerg] 1#1: host not found in upstream "[cluster]" in [file:line]
      

darrenjaneczek avatar Jul 30 '21 14:07 darrenjaneczek

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 02 '21 00:10 stale[bot]

Still relevant

jdbaldry avatar Oct 07 '21 10:10 jdbaldry

Plans to look into this again this quarter. December at the latest.

darrenjaneczek avatar Nov 10 '21 15:11 darrenjaneczek

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 09 '22 16:01 stale[bot]

I believe this is still valid

jdbaldry avatar Jan 10 '22 10:01 jdbaldry

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 19:04 stale[bot]

@darrenjaneczek Is there still desire to get this merged?

jdbaldry avatar Apr 19 '22 08:04 jdbaldry

Yes. I still need to correct some of the identified issues above.

darrenjaneczek avatar Apr 20 '22 05:04 darrenjaneczek

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 15 '22 17:06 CLAassistant

Hello folks, is this still WIP?

gaantunes avatar Jan 26 '23 23:01 gaantunes

I believe so. @darrenjaneczek is this something you want to pick up again?

jdbaldry avatar Feb 06 '23 09:02 jdbaldry

Sorry for this prolonged story. The effort is over a year old now!

The solution as it appears in this PR isn't complete because it creates some errors, itemized here:

  • https://github.com/grafana/jsonnet-libs/pull/624#issuecomment-889938857

My difficulty in picking this up again is that I would need to re-learn how to set up my environment to work with these files. I would probably need some help to get it up and running again, and to refresh my mental model of how to work with nginx.

darrenjaneczek avatar Feb 07 '23 22:02 darrenjaneczek

I'm not sure that the cost of revisiting this issue is worth it at this point in time unless we have seen continued issues with the current behavior so I'm in favor of closing this PR and using it as a starting point if we need to revisit the issue at a later point.

jdbaldry avatar Feb 08 '23 08:02 jdbaldry

That sounds pragmatic. It is rare that any of our APIs require spaces in the URLs, and that particular one that triggered my investigation was worked-around long ago.

darrenjaneczek avatar Feb 08 '23 14:02 darrenjaneczek