Hello folks!
I've just discovered Gotenberg and I configured it in my docker-compose.yaml file, the exposed port is okay, and I can generate PDFs from remote URLs.
However, it only works with remote urls.
Let me explain.
I have a PHP application which must be multidomain.
Let's consider such Compose config:
services
app:
# It exposes port 8000, and requests on "wrong" domains such as 127.0.0.1 return HTTP 400 error
gotenberg:
image: thecodingmachine/gotenberg:5
I'll need to generate PDFs from the app container, therefore I will execute something like this from inside this container:
$ curl --request POST \
--url http://gotenberg:3000/convert/url \
--header "Content-Type: multipart/form-data" \
--form remoteURL=http://mydomain.docker:8000/something.html \
-o result.pdf
However, this will not work: gotenberg's container doesn't know anything about the mydomain.docker host, so I end up having a blank page in result.pdf.
By the way, any curl call to the same address will result in a curl: (7) Failed to connect to mydomain.docker port 8000: Connection refused error.
I even tried echo "mydomain.docker app" >> /etc/hosts, without success (doesn't seem to be taken in account at all).
I could find a hack that would have worked with Curl, by "mocking" the host:
$ curl http://app:8000/ -H"Host: mydomain.docker"
Using this trick, curl will effectively call the app host (the same as the app's container name, valid inside a Docker network), but the resolved host will be mydomain.docker. It just works with curl.
However, it does not go beyond as this trick does not seem to be possible with Gotenberg.
If it was possible to use Gotenberg without a separate Docker container, it would probably be easier, as I could directly install it in the app container and make all queries "from inside" (it would make the image heavier but would be worth it IMO). But I'm not sure copy/pasting config and setup from your repository would be worth it nor maintainable.
I also tried using the /html endpoint, but there are so many CSS, JS and images in the web page that I don't even know how I can achieve that without hundreds of lines of code full of hacks or overengineered stuff.
What I'm almost sure about is that it would probably work in production. I don't use any "complex" setup (just have one dedicated server) so running the docker image alongside all other apps seems pretty okay, and as it would call totally remote addresses (with proper DNS-based hosts), it would work without harm. But for dev, it's not possible.
I'm starting to think that I won't be able to use Gotenberg at all with the setup I have...
Do you have any idea of how I could solve this?
As a side-note, I have chromium installed on the main Docker image (necessary to use Panther for testing).
Should I look further there?
Hello folks!
I've just discovered Gotenberg and I configured it in my
docker-compose.yamlfile, the exposed port is okay, and I can generate PDFs from remote URLs.However, it only works with remote urls.
Let me explain.
I have a PHP application which must be multidomain.
Let's consider such Compose config:
I'll need to generate PDFs from the
appcontainer, therefore I will execute something like this from inside this container:However, this will not work:
gotenberg's container doesn't know anything about themydomain.dockerhost, so I end up having a blank page inresult.pdf.By the way, any
curlcall to the same address will result in acurl: (7) Failed to connect to mydomain.docker port 8000: Connection refusederror.I even tried
echo "mydomain.docker app" >> /etc/hosts, without success (doesn't seem to be taken in account at all).I could find a hack that would have worked with Curl, by "mocking" the host:
Using this trick,
curlwill effectively call theapphost (the same as the app's container name, valid inside a Docker network), but the resolved host will bemydomain.docker. It just works withcurl.However, it does not go beyond as this trick does not seem to be possible with Gotenberg.
If it was possible to use Gotenberg without a separate Docker container, it would probably be easier, as I could directly install it in the
appcontainer and make all queries "from inside" (it would make the image heavier but would be worth it IMO). But I'm not sure copy/pasting config and setup from your repository would be worth it nor maintainable.I also tried using the
/htmlendpoint, but there are so many CSS, JS and images in the web page that I don't even know how I can achieve that without hundreds of lines of code full of hacks or overengineered stuff.What I'm almost sure about is that it would probably work in production. I don't use any "complex" setup (just have one dedicated server) so running the docker image alongside all other apps seems pretty okay, and as it would call totally remote addresses (with proper DNS-based hosts), it would work without harm. But for dev, it's not possible.
I'm starting to think that I won't be able to use Gotenberg at all with the setup I have...
Do you have any idea of how I could solve this?
As a side-note, I have chromium installed on the main Docker image (necessary to use Panther for testing).
Should I look further there?