Cannot view or download PDF - mostly stock settings with Docker image

I am running Debian Bullseye on an AWS EC2 instance, trying to get the last piece of InvoiceNinja to work – PDF downloads. I’ve deleted my customized docker setup and went back to basics with the stock setup from https://github.com/invoiceninja/dockerfiles . Even with this, I am struggling to get PDF downloading to work.

I am wanting to use snappdf to generate the PDFs, which is the default set in the env file.

Using commit:

$ git show --format=%H
27b6c82fe45a45a2ba0724ef30bb7ae1fd87104a

Showing only the changes from the default:

$ git diff >> /dev/shm/diff
admin@ip-172-31-16-82:~/build/docker/invoiceninja$ cat /dev/shm/diff 
diff --git a/docker-compose.yml b/docker-compose.yml
index fdd5760..ae1fe4b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -15,7 +15,8 @@ services:
     # Run webserver nginx on port 80
     # Feel free to modify depending what port is already occupied
     ports:
-      - "80:80"
+      - "redactedport:80"
+      - "9000:9000"
       #- "443:443"
     networks:
       - invoiceninja
diff --git a/env b/env
index 931eb0b..9600b19 100644
--- a/env
+++ b/env
@@ -1,6 +1,7 @@
 # IN application vars
-APP_URL=http://in.localhost:8003
-APP_KEY=<insert your generated key in here>
+#APP_URL=https://in.localhost:8003
+APP_URL=http://redacteddomain.com:redactedport
+APP_KEY=base64:redactedkey=
 APP_DEBUG=true
 REQUIRE_HTTPS=false
 PHANTOMJS_PDF_GENERATION=false
@@ -19,18 +20,18 @@ DB_PASSWORD=ninja
 # Default to these values if empty
 # IN_USER_EMAIL=admin@example.com
 # IN_PASSWORD=changeme!
-IN_USER_EMAIL=
+IN_USER_EMAIL=redactedadmin@redacteddomain.com
 IN_PASSWORD=
 
 # Mail options
-MAIL_MAILER=log
-MAIL_HOST=smtp.mailtrap.io
-MAIL_PORT=2525
-MAIL_USERNAME=null
-MAIL_PASSWORD=null
-MAIL_ENCRYPTION=null
-MAIL_FROM_ADDRESS='user@example.com'
-MAIL_FROM_NAME='Self Hosted User'
+MAIL_MAILER=smtp
+MAIL_HOST=smtp.gmail.com
+MAIL_PORT=587
+MAIL_USERNAME=redactedmailer@redacteddomain.com
+MAIL_PASSWORD=redactedpass
+MAIL_ENCRYPTION=tls
+MAIL_FROM_ADDRESS='redactedmailer@redacteddomain.com'
+MAIL_FROM_NAME='InvoiceNinja'
 
 # MySQL
 MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword

I thought that the APP_URL parameter in the env file was not important due to the post here, but it looks like it plays a more important role these days; whenever I click Download on a PDF that I’ve generated inside InvoiceNinja, it opens a new tab in my browser which is pointed at the entry in APP_URL. Even after changing that to point at the domain where I’m hosting InvoiceNinja, it will not download; it just shows a spinning loading icon forever.

Monitoring the output of the nginx container, after a delay I see the following log message:

2022/03/07 05:01:07 [error] 33#33: *43 upstream timed out (110: Connection timed out) while reading response header from upstream, client: redactedip, server: _, request: "POST /api/v1/live_preview?entity=invoice HTTP/1.1", upstream: "fastcgi://redacted_docker_local_ip:9000", host: "redacteddomain.com:redactedport", referrer: "http://redacteddomain.com:redactedport/"

I have tried various random things I found online for a couple days now, to no avail.

Hi,

If you’re using a proxy it may help to add TRUSTED_PROXIES=*

https://invoiceninja.github.io/docs/env-variables/

@david any thoughts?

Thanks @hillel . I will try that again now that I’ve reset everything to basic defaults. But it did not work earlier in my heavily customized setup.

EDIT: I will eventually be using this through a reverse proxy, but I am connecting directly to the exposed docker port right now, just to try to get things working.

EDIT 2: No dice :frowning:

Not sure, when things deviate from the standard docker compose we have it is tough to provide quality advice.

@david

As I’m showing in my OP, I’m only changing the absolute bare minimum from the default…

Did you come across a solution?
Similar issue - Docker image - issues with file uploads - #21 by sdggq