plantuml / plantuml-server

PlantUML Online Server
https://plantuml.com/
GNU General Public License v3.0
1.6k stars 463 forks source link

Hostpath includes protocol and is confuses http/https when behind a proxy #207

Closed ctn closed 2 years ago

ctn commented 2 years ago

https://github.com/plantuml/plantuml-server/blob/da290a15fe8d8b8b156dcaf1516b28134e24afe8/src/main/webapp/index.jsp#L10

I have nginx handle SSL and by the time it gets to this service, the request protocol is HTTP. When this hostpath is used to construct URLs, they come back to the client browser as HTTP instead of HTTPS.

A solution is simply to drop hostpath and use relative URIs.

Is there any other reason to use hostpath here?

If not, I have a simple PR that will fix this. Thanks.

arnaudroques commented 2 years ago

If not, I have a simple PR that will fix this. Thanks.

You can go ahead, we will be glad to merge it. Thanks!

HeinrichAD commented 2 years ago

Is there any other reason to use hostpath here?

hostpath does also include the context path of the URL.

https://github.com/plantuml/plantuml-server/blob/3763ee737e19b627c484ac44a098ca7fe209ee62/src/main/java/net/sourceforge/plantuml/servlet/PlantUmlServlet.java#L266-L267

So, the problem with your changes in PR #208 is, that it breaks the PlantUML Base URL path feature.

I think your problem should be solved if you add proxy_set_header X-Forwarded-Proto $scheme; inside your nginx configuration.

Maybe you will find one of the two examples helpful:

ctn commented 2 years ago

proxy_set_header X-Forwarded-Proto $scheme does indeed fix the scheme issue, and is a better solution. Thanks.