Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PlantUML behind a reverse proxy #79

Closed
eschaarschmidt opened this issue Oct 18, 2018 · 3 comments · Fixed by #206
Closed

Use PlantUML behind a reverse proxy #79

eschaarschmidt opened this issue Oct 18, 2018 · 3 comments · Fixed by #206

Comments

@eschaarschmidt
Copy link

eschaarschmidt commented Oct 18, 2018

Hi everyone,

i try to use plantUML behind a reverse proxy and have some problems with it.

My plantuml server ist running at:
http://plantuml.pcf.tld/

The request for plantuml goes to:
http://intra.domain.tld/plantuml which reverse proxys requests to
http://plantuml.pcf.tld/

Direct Requests to png/svg are working, for example:
http://intra.domain.tld/plantuml/png/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000 -> works fine

What is not working are links in the jsp singlepage application.

Whent i try to access: http://intra.domain.tld/plantuml/
it redirects to http://intra.domain.tld/uml/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000 -> which is the wrong context root ("uml" instead of "plantuml").

When i try to access the singlepage application with a direkt request like:
http://intra.domain.tld/plantuml/uml/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000
the page loads, but all links in build against the wrong URL ( it builds the links against http://plantuml.pcf.tld instead of http://intra.domain.tld/plantuml )

I would really like to use the jsp singlepage with the reverse Proxy. I have not found a way to fix this.
The index.jsp gets the host URI from:
<c:set var="hostpath" value="${scheme}://${pageContext.request.serverName}${port}${contextroot}" />

As the server where plantuml is running is not the same that delivers the webpages, this does not work for my scenario.

Can you make the baseurl where plantuml is building on configurable or have any advice for me?

@paddy-hack
Copy link
Contributor

Found myself in a similar ⛵

Used the approach from #80 to make the plantuml-server serve on /plantuml rather than / and reverse proxying was all good again.

@HeinrichAD
Copy link
Collaborator

HeinrichAD commented May 31, 2021

I know this Issue is quite old but I faced the same problem.

If there is a solution in the meantime, please let me know. Perhaps we could add an example in the README.

Situation as above:

  1. plantuml-server as docker container
  2. nginx server as another docker container which should work as proxy

Dirty workaround

nginx.config

location /plantuml/ {
    proxy_set_header HOST $host;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    rewrite ^(/plantuml)+/(.*) /plantuml/$2 break;    # the messy part
    proxy_pass http://plantuml-server:8080/;
}

docker-compose.yml

version: '3.3'

services:
  plantuml-server:
    build:
      context: https://github.com/plantuml/plantuml-server.git
      dockerfile: Dockerfile.jetty
      args:
        BASE_URL: plantuml
    image: plantuml/plantuml-server:local
    container_name: plantuml-server
    ports:
      - 8080:8080

Again. If anyone knows of a clean solution, I would greatly appreciate it.

Related: #178

@brusa-elektronik-muenchen
Copy link

I had the same problem for a vanilla container (not building via Dockerfile). The solution can be found here, and just requires you to add the http-forwarded as a command-line argument.

Here is my updated docker-config file:

version: '3.3'

services:
  plantuml-server:
    image: plantuml/plantuml-server:jetty
    container_name: plantuml
    ports:
      - 8080:8080
    command: --module=http-forwarded

HeinrichAD pushed a commit to HeinrichAD/plantuml-server that referenced this issue Jul 19, 2023
The "special" value of `ROOT` will serve requests on `/`.  Any other
value should serve on `/$BASE_URL` (as long as there are no slashes
in `BASE_URL` at least).

The default has been set to `plantuml` to better match documentation
in the README.md file.

Re plantuml#80, may help with plantuml#79.
HeinrichAD pushed a commit to HeinrichAD/plantuml-server that referenced this issue Jul 19, 2023
The "special" value of `ROOT` will serve requests on `/`.  Any other
value should serve on `/$BASE_URL` (as long as there are no slashes
in `BASE_URL` at least).

The default has been set to `plantuml` to better match documentation
in the README.md file.

Re plantuml#80, may help with plantuml#79.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants