plantuml / plantuml-server

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

docker-compose http_proxy #230

Closed davama closed 1 year ago

davama commented 2 years ago

Hello,

Having a hard time getting plantuml to be able to access pre-build resources on the internet:

for example:

@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml

Person(personAlias, "Label", "Optional Description")
Container(containerAlias, "Label", "Technology", "Optional Description")
System(systemAlias, "Label", "Optional Description")

Rel(personAlias, containerAlias, "Label", "Optional Technology")
@enduml

Here is my docker-compose.yml file:

version: '3'

services:
  plantuml:
    image: plantuml/plantuml-server:tomcat
    container_name: plantuml
    restart: unless-stopped
    volumes:
      - ./data:/data
    ports:
      - 8080:8080
    environment:
        http_proxy: http://localhost:3128
        https_proxy: http://localhost:3128
        CATALINA_OPTS: >-
          -Dhttp.proxyHost=localhost
          -Dhttp.proxyPort=3128
          -Dhttps.proxyHost=localhost
          -Dhttps.proxyPort=3128
          -Dhttp.nonProxyHosts=localhost

I am running nginx loadbalancer for port 3128 to my web proxies on the host itself. Hence localhost. To make sure it's clear, nginx is on the host, plantuml is on docker.

These is the error log i get:

plantuml    | issue raw.githubusercontent.com java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused (Connection refused)

What am i doing wrong? Any input is much appreciated.

Thank you, Dave

davama commented 2 years ago

Also, i can confirm that 3128 on the host works fine:

[root@localhost ~]# env | grep _proxy
https_proxy=http://localhost:3128
http_proxy=http://localhost:3128

[root@localhost ~]# curl -I https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml 
HTTP/1.1 200 Connection established

HTTP/2 200 
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: "86fcfe396c870b9e7728316dc2cf1e9d5e83da73af08f62dc771402e24a0c827"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: AA86:5CF3:45B3B:D9FDC:6299F57D
accept-ranges: bytes
date: Fri, 03 Jun 2022 12:35:33 GMT
via: 1.1 varnish
x-served-by: cache-hnd18726-HND
x-cache: MISS
x-cache-hits: 0
x-timer: S1654259733.007631,VS0,VE177
vary: Authorization,Accept-Encoding,Origin
access-control-allow-origin: *
x-fastly-request-id: f77799e990a743ae6084291bed90f07d456ce2fa
expires: Fri, 03 Jun 2022 12:40:33 GMT
source-age: 0
content-length: 5587
hutec commented 1 year ago

I was facing a similar issue and what finally worked was

version: '3'

services:
  plantuml:
    image: plantuml/plantuml-server:jetty
    container_name: plantuml
    ports:
      - 8080:8080
    environment:
      ALLOW_PLANTUML_INCLUDE: "true"
      _JAVA_OPTIONS: >-
         -Dhttp.proxyHost=172.17.0.1
         -Dhttp.proxyPort=3128
         -Dhttps.proxyHost=172.17.0.1
         -Dhttps.proxyPort=3128

So you could try using _JAVA_OPTIONS instead of CATALINA_OPTS

davama commented 1 year ago

@hutec thank you for that! I got it to work. Woohoo

Closing