diff --git a/paperless.conf.example b/paperless.conf.example index a17aac327..3f9e2e98d 100644 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -80,6 +80,11 @@ PAPERLESS_PASSPHRASE="secret" # as is "example.com,www.example.com", but NOT " example.com" or "example.com," #PAPERLESS_ALLOWED_HOSTS="example.com,www.example.com" +# To host paperless under a subpath url like example.com/paperless you set +# this value to /paperless. No trailing slash! +# +# https://docs.djangoproject.com/en/1.11/ref/settings/#force-script-name +#PAPERLESS_FORCE_SCRIPT_NAME="" ############################################################################### #### Software Tweaks #### diff --git a/src/documents/admin.py b/src/documents/admin.py index 7cba10c74..16f544fb6 100644 --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -70,9 +70,14 @@ def created_(self, obj): created_.short_description = "Created" def thumbnail(self, obj): + if settings.FORCE_SCRIPT_NAME: + src_link = "{}/fetch/thumb/{}".format( + settings.FORCE_SCRIPT_NAME, obj.id) + else: + src_link = "/fetch/thumb/{}".format(obj.id) png_img = self._html_tag( "img", - src="/fetch/thumb/{}".format(obj.id), + src=src_link, width=180, alt="Thumbnail of {}".format(obj.file_name), title=obj.file_name diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 2e525ae41..95d16bb66 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -47,7 +47,8 @@ if _allowed_hosts: ALLOWED_HOSTS = _allowed_hosts.split(",") - +FORCE_SCRIPT_NAME = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME") + # Application definition INSTALLED_APPS = [