Can't get invoice preview/download to work when behind NginxProxyManager

Version ie <v5.10.46>

Environment <Docker/Shared Hosting/Zip/Other>

Docker

Checklist

  • Can you replicate the issue on our v5 demo site https://demo.invoiceninja.com or Invoice Ninja
  • Have you searched existing issues?yes
  • Have you inspected the logs in storage/logs/laravel.log for any errors? yes

Describe the bug

PDF preview/download/print does’nt work when access the selfhosed server via reverseproxy manger like NPM

Steps To Reproduce

Create a client from client tab, then go to invoice and select a product/service and scroll down in invoice section, pdf preview keeps on loading until it fails. Can’t get to print nor download or preview when we try to access it behind the NPM(nginxproxymanger). i’ve tried setting domain name and IP too in trusted proxy in ENV

Expected Behavior

I exepected it to load and able to download as it normally does when access the same page via direct IP address like 192.168.0.44:80.

Additional context

Screenshots

Logs

192.168.160.4 - 11/Nov/2024:14:29:02 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:02 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:02 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:02 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:02 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:02 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:03 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “POST /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “POST /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:05 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:30 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:30 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:32 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:32 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:35 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:35 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:35 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:36 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:29:37 +0000 “POST /index.php” 200
2024-11-11 14:29:40,202 INFO reaped unknown pid 724 (exit status 0)
2024-11-11 14:29:40,202 INFO reaped unknown pid 726 (exit status 0)
2024-11-11 14:29:40,202 INFO reaped unknown pid 729 (exit status 0)
2024-11-11 14:29:40,202 INFO reaped unknown pid 730 (exit status 0)
192.168.160.4 - 11/Nov/2024:14:29:48 +0000 “GET /index.php” 200
2024-11-11 14:29:50,243 INFO reaped unknown pid 888 (exit status 0)
2024-11-11 14:29:50,243 INFO reaped unknown pid 886 (exit status 0)
2024-11-11 14:29:50,244 INFO reaped unknown pid 891 (exit status 0)
2024-11-11 14:29:50,244 INFO reaped unknown pid 892 (exit status 0)
2024-11-11 14:30:00 Running [queue-size-job] … 30.92ms DONE
2024-11-11 14:30:00 Running [stale-invoice-job] … 5.99ms DONE
2024-11-11 14:30:00 Running [Callback] … 19.86ms DONE
2024-11-11 14:30:00 App\Jobs\Subscription\CleanStaleInvoiceOrder … RUNNING
2024-11-11 14:30:00 App\Jobs\Ninja\QueueSize … RUNNING
2024-11-11 14:30:00 App\Jobs\Ninja\QueueSize … 15.24ms DONE
2024-11-11 14:30:00 App\Jobs\Subscription\CleanStaleInvoiceOrder 27.72ms DONE
192.168.160.4 - 11/Nov/2024:14:30:20 +0000 “POST /index.php” 200
192.168.160.4 - 11/Nov/2024:14:30:20 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:30:20 +0000 “POST /index.php” 200
192.168.160.4 - 11/Nov/2024:14:30:23 +0000 “POST /index.php” 200
2024-11-11 14:30:25,707 INFO reaped unknown pid 1046 (exit status 0)
2024-11-11 14:30:25,707 INFO reaped unknown pid 1048 (exit status 0)
2024-11-11 14:30:25,708 INFO reaped unknown pid 1051 (exit status 0)
2024-11-11 14:30:25,708 INFO reaped unknown pid 1052 (exit status 0)
INFO No scheduled commands are ready to run.
192.168.160.4 - 11/Nov/2024:14:31:07 +0000 “PUT /index.php” 200
192.168.160.4 - 11/Nov/2024:14:31:07 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:31:09 +0000 “PUT /index.php” 200
192.168.160.4 - 11/Nov/2024:14:31:09 +0000 “GET /index.php” 200
INFO No scheduled commands are ready to run.
INFO No scheduled commands are ready to run.
192.168.160.4 - 11/Nov/2024:14:33:07 +0000 “GET /index.php” 200
INFO No scheduled commands are ready to run.
2024-11-11 14:35:00 Running [queue-size-job] … 28.45ms DONE
2024-11-11 14:35:00 Running [Callback] … 21.82ms DONE
2024-11-11 14:35:01 App\Jobs\Ninja\QueueSize … RUNNING
2024-11-11 14:35:01 App\Jobs\Ninja\QueueSize … 6.91ms DONE
INFO No scheduled commands are ready to run.
INFO No scheduled commands are ready to run.
192.168.160.4 - 11/Nov/2024:14:37:26 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:29 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:29 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:29 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:31 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:31 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:31 +0000 “GET /index.php” 200
192.168.160.4 - 11/Nov/2024:14:37:31 +0000 “GET /index.php” 200
INFO No scheduled commands are ready to run.
2024-11-11 14:38:33,632 INFO reaped unknown pid 1236 (exit status 0)
2024-11-11 14:38:33,634 INFO reaped unknown pid 1238 (exit status 0)
2024-11-11 14:38:33,634 INFO reaped unknown pid 1262 (exit status 0)
2024-11-11 14:38:33,634 INFO reaped unknown pid 1241 (exit status 0)
2024-11-11 14:38:33,634 INFO reaped unknown pid 1242 (exit status 0)
2024-11-11 14:38:33,634 INFO reaped unknown pid 1268 (exit status 0)
2024-11-11 14:38:33,634 INFO reaped unknown pid 1286 (exit status 0)
2024-11-11 14:38:33,635 INFO reaped unknown pid 1368 (exit status 0)
2024-11-11 14:38:33,635 INFO reaped unknown pid 1261 (exit status 0)
192.168.160.4 - 11/Nov/2024:14:37:32 +0000 “POST /index.php” 500
192.168.160.4 - 11/Nov/2024:14:37:37 +0000 “GET /index.php” 500
2024-11-11 14:38:38,166 INFO reaped unknown pid 1423 (exit status 0)
2024-11-11 14:38:38,166 INFO reaped unknown pid 1438 (exit status 0)
2024-11-11 14:38:38,167 INFO reaped unknown pid 1520 (exit status 0)
2024-11-11 14:38:38,167 INFO reaped unknown pid 1416 (exit status 0)
2024-11-11 14:38:38,167 INFO reaped unknown pid 1396 (exit status 0)
2024-11-11 14:38:38,167 INFO reaped unknown pid 1397 (exit status 0)
2024-11-11 14:38:39,169 INFO reaped unknown pid 1391 (exit status 0)
2024-11-11 14:38:39,169 INFO reaped unknown pid 1393 (exit status 0)
2024-11-11 14:38:39,169 INFO reaped unknown pid 1422 (exit status 0)

Hi,

Are there any details about the error in storage/logs?

Hi, here are the logs from storage directory

@hillel

If you’re using the SnapPDF PDF generator you may want to try changing to hosted_ninja

Now i lost preview in both via proxy and directly via IP.

You may want to try using telnet from the server to check that the host/port is reachable

All my ports are free and i can very well reach with just ip and port

It may help to add TRUSTED_PROXIES=* to the .env file

its been added since default.
ill attach my compose and env.
please go through
services:
server:
container_name: invoiceninja-server
image: nginx
restart: always
env_file: env
volumes:
# Vhost configuration
#- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
- ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
- ./docker/app/public:/var/www/app/public:ro
depends_on:
- app
# Run webserver nginx on port 80
# Feel free to modify depending what port is already occupied
ports:
- “867:80”

- “4413:443”

networks:
  - invoiceninja
extra_hosts:
  - "invoice.skynetlab.in:192.168.66.10 " #host and ip

app:
image: invoiceninja/invoiceninja:5
container_name: invoiceninja-app
env_file: env
restart: always
volumes:
- ./config/hosts:/etc/hosts:ro
- ./docker/app/public:/var/www/app/public:rw,delegated
- ./docker/app/storage:/var/www/app/storage:rw,delegated
- ./config/php/php.ini:/usr/local/etc/php/php.ini
- ./config/php/php-cli.ini:/usr/local/etc/php/php-cli.ini

depends_on:
  - db
networks:
  - invoiceninja
extra_hosts:
  - "invoice.skynetlab.in:192.168.66.10 " #host and ip

db:
image: mysql:8
container_name: invoiceninja-db

When running on ARM64 use MariaDB instead of MySQL

image: mariadb:10.4

For auto DB backups comment out image and use the build block below

build:

context: ./config/mysql

restart: always
env_file: env
volumes:
  - ./docker/mysql/data:/var/lib/mysql:rw,delegated

  # remove comments for next 4 lines if you want auto sql backups
  #- ./docker/mysql/bak:/backups:rw
  #- ./config/mysql/backup-script:/etc/cron.daily/daily:ro
  #- ./config/mysql/backup-script:/etc/cron.weekly/weekly:ro
  #- ./config/mysql/backup-script:/etc/cron.monthly/monthly:ro
networks:
  - invoiceninja
extra_hosts:
  - "invoice.skynetlab.in:192.168.66.10 " #host and ip

THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.

cron:

image: invoiceninja/invoiceninja:alpine-4

volumes:

  # - ./docker/app/public:/var/www/app/public:rw,delegated
  # - ./docker/app/storage:/var/www/app/storage:rw,delegated
  # - ./docker/app/public/logo:/var/www/app/public/logo:rw,delegated

entrypoint: |

/bin/sh -c 'sh -s <<EOF

trap “break;exit” SIGHUP SIGINT SIGTERM

sleep 300s

while /bin/true; do

./artisan ninja:send-invoices

./artisan ninja:send-reminders

sleep 1d

done

EOF’

networks:

- invoiceninja

networks:
invoiceninja:

env file

IN application vars

APP_URL=https://192.168.66.10:867/

APP_KEY=base64:HCb7IFcne3iLSzAqxo/Zcf24ToG+lqBH9lukMW/G0Xk=

APP_DEBUG=false

REQUIRE_HTTPS=false

PHANTOMJS_PDF_GENERATION=false

PDF_GENERATOR=snappdf

TRUSTED_PROXIES=*

QUEUE_CONNECTION=database

DB connection

DB_HOST=db

DB_PORT=3306

DB_DATABASE=ninja

DB_USERNAME=ninja

DB_PASSWORD=ninja

Create initial user

Default to these values if empty

[email protected]

IN_PASSWORD=changeme!

[email protected]

IN_PASSWORD=xxxxxxxxx

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=‘[email protected]

MAIL_FROM_NAME=‘Self Hosted User’

MySQL

MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword

MYSQL_USER=ninja

MYSQL_PASSWORD=ninja

MYSQL_DATABASE=ninja

GoCardless/Nordigen API key for banking integration

NORDIGEN_SECRET_ID=

NORDIGEN_SECRET_KEY=

V4 env vars

DB_STRICT=false

APP_CIPHER=AES-256-CBC

Sorry, I’m not sure

You may want to try one of the automated installers