1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-12-30 11:30:35 +00:00
plantuml-server/examples/nginx-simple
Florian 99f85c0c9b Use relative paths as far as possible.
Switch from absolute paths `hostpath` to relative paths `contextpath`.
Unfortunately, for the url input javascript is necessary to resolve the
relative url.
Also see Issue #205.
2023-02-24 09:26:48 +01:00
..
docker-compose.yml Use relative paths as far as possible. 2023-02-24 09:26:48 +01:00
nginx.conf add nginx reverse proxy examples 2021-12-26 23:48:51 +01:00
README.md Use relative paths as far as possible. 2023-02-24 09:26:48 +01:00

Nginx simple reverse proxy example

References:

Quick start

Be sure to have docker-compose.yml and nginx.conf inside your current working directory.

# start nginx and plantuml server
docker-compose up -d

# stop nginx and plantuml server
docker-compose down

Check with docker ps if both container are up and running:

$ docker ps
CONTAINER ID   IMAGE                            COMMAND                  CREATED         STATUS         PORTS                               NAMES
217e753a0dcf   plantuml/plantuml-server:jetty   "/entrypoint.sh"         4 seconds ago   Up 3 seconds   8080/tcp                            plantuml-server
9b1290c100f5   nginx:alpine                     "/docker-entrypoint.…"   4 seconds ago   Up 3 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx

Open http://localhost inside your browser. YEAH! You are now using PlantUML behind a simple Nginx reverse proxy.

Nginx configuration

...

# PlantUML
location / {
    proxy_set_header  HOST               $host;
    proxy_set_header  X-Forwarded-Host   $host;
    proxy_set_header  X-Forwarded-Proto  $scheme;

    proxy_pass http://plantuml-server:8080/;
}

...
  • location / to reverse complete server
  • proxy_set_header HOST $host and proxy_set_header X-Forwarded-Host $host to replaces local plantuml server ip with FQDN
  • proxy_set_header X-Forwarded-Proto $scheme to use reverse proxy protocol schema instead of communication schema between reverse proxy and plantuml server
  • proxy_pass http://plantuml-server:8080/ to set reverse proxy path to plantuml server. Use the docker container name plantuml-server instead of ip addresses.

Nginx and PlantUML server

version: "3"

services:
  plantuml-server:
    image: plantuml/plantuml-server:jetty
    container_name: plantuml-server
    environment:
      - TZ=Europe/Berlin

  nginx:
    image: nginx:alpine
    container_name: nginx
    ports:
      - "80:80"
    environment:
      - TZ=Europe/Berlin
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
  • Set container_name to use them instead of e.g. ip addresses
  • Set the environment TZ the ensure the same timezone. For example to server timezone (cat /etc/timezone)?
  • plantuml-server
    • plantuml-server already exposes port 8080 to it's own local network (but not outside). Since plantuml-server and nginx are sharing a network, nginx can reach plantuml-server without further settings.
  • nginx
    • open/link port 80 to the outside
    • ./nginx.conf:/etc/nginx/nginx.conf:ro to use your own Nginx configuration (readonly)

Useful commands

# see whats going on inside your docker containers
docker logs --tail 50 --follow --timestamps nginx
docker logs --tail 50 --follow --timestamps plantuml-server