Simple Invoices PDF Export Formatting and Logo Missing – NGinx

Written by James McDonald

March 5, 2014

I am running Simple Invoices on Nginx.

I have basic authentication switched on:

 location /simple_invoices/ {
    auth_basic  "Simple Invoices";
    auth_basic_user_file /etc/nginx/auth/htpasswd;

The problem I have been seeing is that the formatting and the Logo is missing from my exported PDFs


Examining the nginx access log I’m seeing 401 “Unauthorized” errors - - [05/Mar/2014:00:00:21 +0000] "HEAD /simple_invoices/templates/invoices/default/style.css HTTP/1.1" 401 0 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7) Gecko/20040803 Firefox/0.9.3" - - [05/Mar/2014:00:00:21 +0000] "GET /simple_invoices/templates/invoices/default/style.css HTTP/1.0" 401 188 "-" "-" - - [05/Mar/2014:00:00:22 +0000] "HEAD /simple_invoices/templates/invoices/logos/logo.png HTTP/1.1" 401 0 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7) Gecko/20040803 Firefox/0.9.3" - - [05/Mar/2014:00:00:22 +0000] "GET /simple_invoices/templates/invoices/logos/logo.png HTTP/1.0" 401 188 "-" "-"

The cause

The Simple Invoices application is making a web request to a basic authentication protected location and because it isn’t aware it has to authenticate, it is receiving an Access Denied. So the CSS and logo cannot be applied to the PDF

The fix

On the Web Server hosting your Simple Invoices installation edit the /etc/hosts file and add an entry for the server name or domain you access simple invoices with pointing to the loop back address (


# if you access your simple invoices with
# or for

The above entry will cause the Simple Invoices to access the CSS and logo via the loopback IP

Next white list the loopback IP as allowed in the NGINX configuration file.

  location /simple_invoices/ {
    satisfy any;
    deny all;
    auth_basic  "Simple Invoices";
    auth_basic_user_file /etc/nginx/auth/htpasswd;

## run this at a command prompt to pick up the change
# service nginx reload

With these changes the logs now show that the resources need by the Simple Invoices PDF Export and Send via email are now working. Notice the return code of 200 idicating a successful request and that the request is from the loopback address of - - [05/Mar/2014:00:26:39 +0000] "GET /simple_invoices/templates/invoices/default/style.css HTTP/1.0" 200 965 "-" "-" - - [05/Mar/2014:00:26:39 +0000] "GET /simple_invoices/templates/invoices/logos/jmits-logo.png HTTP/1.0" 200 6897 "-" "-" - jmcd [05/Mar/2014:00:26:45 +0000] "GET /simple_invoices/index.php?module=export&view=invoice&id=3&format=pdf HTTP/1.1" 200 542737 "" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36"

With the result being a nicely formatted PDF




Nginx bypass basic authentication

Simple Invoice Missing Logo

1 Comment

  1. Philippe

    Thanks a lot for this post. I was having the same issue on my server. I didn’t have the access denied like you but adding the server name in the hosts files fixed it!


Submit a Comment

Your email address will not be published.

You May Also Like…


Zebra Printer Language The above website has a page where you can enter ZPL and it...

PHP Iterators

Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many...

PHP array_map Multiple Arrays

array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each...