0

I have tomcat running and I'm trying to route to the main app which is localhost:8080/AppName/#/ through nginx. I am able to reach the url by using hostname:8080/AppName/#/ but when I use nginx I get Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986. This is likely nginx renaming the # symbol because using nginx to rout to localhost:8080/AppName works without issue, i just need to then go to hostname/#/ to reach my localhost:8080/AppName/#/ route.

Thus nginx route:

location / {
   proxy_pass http://localhost:8080/AppName/#/;
}

Any idea how to get around this # character issue with nginx and/or tomcat (9)?

The only fix I found didn't work (Tomcat 8 is not able to handle get request with '|' in query parameters?) . I also tried directly encoding it as %23.

Kevin Danikowski
  • 4,620
  • 6
  • 41
  • 75
  • 1
    Anything from the `#` onwards is the [URL fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Generic_syntax) and is not sent to the server. It is for the exclusive use of the browser and client-side javascript. – Richard Smith Dec 31 '19 at 19:21
  • @RichardSmith are you sure it's a fragment since it's wrapped with `/` on each end? So a url to the login page would be `AppName/#/Login`. The `/#/` exists for every page on the app. – Kevin Danikowski Dec 31 '19 at 19:46
  • 1
    Your URL `hostname:8080/AppName/#/`, the server at `hostname:8080` will receive an http(s) request line that looks like `GET /AppName/`. – Richard Smith Dec 31 '19 at 19:52
  • You're right, looking into it I found http://www.jenitennison.com/2011/03/06/hash-uris.html which suggests that i will be unable to route with the hash on the nginx end. Thank you @RichardSmith – Kevin Danikowski Dec 31 '19 at 19:53
  • @RichardSmith , any insights on SEO implications of this by chance? If you know about it at all – Kevin Danikowski Dec 31 '19 at 19:56

0 Answers0