Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy at non root URL #253

viharm opened this Issue Aug 10, 2017 · 10 comments


None yet
6 participants
Copy link

viharm commented Aug 10, 2017

This seems like a very good application. Thank you for efforts in creating this app. I respect the vision and agree with it.

I am trying to deploy this behind in existing environment which has an Apache installation serving several websites.

I would like to use my Apache webserver as a reverse proxy to access paperless. However I am also deploying this at a non-root URL of an existing virtual host, e.g., https://mydomain.tld/paperless

When I setup the reverse proxy, the Django service keeps throwing back the root URL, thus failing. Is there a configuration for setting this path/URL?


@viharm viharm changed the title Deploye at non root URL Deploy at non root URL Aug 10, 2017


This comment has been minimized.

Copy link

danielquinn commented Aug 14, 2017

I've never done something like that before, but a cursory search online pointed me to FORCE_SCRIPT_NAME which might be your best bet.

I suggest editing paperless/ and adding FORCE_SCRIPT_NAME = "paperless" to the bottom and restarting the server to see if that works. If it does, issue a pull request that follows the other settings vars use of environment variables and I'll roll it into master.

If it doesn't work however, I'm afraid I don't know how to do that :-( I'm not opposed to making it work though, should someone else know how to do it.


This comment has been minimized.

Copy link

MasterofJOKers commented Aug 14, 2017

I only know how to do this for deployments using uWSGI. This is part of my nginx config for another project:

location /blog/ {
                include         uwsgi_params;
                uwsgi_param SCRIPT_NAME /blog;
                # tell uwsgi to remove SCRIPT_NAME from the URL
                uwsgi_modifier1 30;

Googling for SCRIPT_NAME, it seems also possible to set this as environment variable for django in a wsgi file. But that setting sounds like it should do the job.


This comment has been minimized.

Copy link

kmlucy commented Jan 14, 2018

I run my instance at /paperless/. I run in docker, so I just run this before it starts to modify the necessary hardcoded URLs:

sed -i 's=/fetch=/paperless/fetch=' /usr/src/paperless/src/documents/
sed -i -e 's=/admin/login=/paperless/admin/login=' -e 's=/static/=/paperless/static/=' -e 's=/media/=/paperless/media/=' /usr/src/paperless/src/paperless/
sed -i -e 's=r"^=r"^paperless/=' -e 's=r"admin=r"paperless/admin=' -e 's=r""=r"paperless"=' /usr/src/paperless/src/paperless/

It's not the cleanest way, but it does work.


This comment has been minimized.

Copy link

danielquinn commented Apr 13, 2018

Hi guys, I finally got around to fixing this tonight -- I hope -- your own responses will help determine if that's true ;-) Just do a git pull to get the changes.

@kmlucy, thanks to your URL hack above, I was able to track down all of the hard-coded URLs and replace them with properly named ones. Hopefully that will clean things up for you. @ovv's advice in #323 about configuring Nginx however may still be necessary. YMMV.

Assuming this works out, would any of you care to write some documentation about how you've made Paperless work on a subfolder?

@ovv ovv referenced this issue Apr 13, 2018


Django runserver #329


This comment has been minimized.

Copy link

kmlucy commented Apr 14, 2018

I updated Paperless, removed my URL hack, and updated my NGINX config. Now I am getting a DisallowedRedirect error when I try to navigate to


Request Method: GET
Request URL:

Django Version: 1.11.12
Python Version: 3.6.3
Installed Applications:
Installed Middleware:


File "/usr/lib/python3.6/site-packages/django/core/handlers/" in inner
  41.             response = get_response(request)

File "/usr/lib/python3.6/site-packages/django/core/handlers/" in _legacy_get_response
  249.             response = self._get_response(request)

File "/usr/lib/python3.6/site-packages/django/core/handlers/" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/lib/python3.6/site-packages/django/core/handlers/" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/lib/python3.6/site-packages/django/views/generic/" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/usr/lib/python3.6/site-packages/django/views/generic/" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/usr/lib/python3.6/site-packages/django/views/generic/" in get
  193.                 return http.HttpResponsePermanentRedirect(url)

File "/usr/lib/python3.6/site-packages/django/http/" in __init__
  431.             raise DisallowedRedirect("Unsafe redirect to URL with protocol '%s'" % parsed.scheme)

Exception Type: DisallowedRedirect at /
Exception Value: Unsafe redirect to URL with protocol 'admin'

This comment has been minimized.

Copy link

danielquinn commented Apr 16, 2018

@kmlucy yeah I screwed that one up -- I don't know how to make it work for people running paperless on a subdirectory, sorry.

I've reverted that one line to the hard-coded redirect to /admin/, so you'll need to apply that patch to run it until someone sends me a PR that will make it work.


This comment has been minimized.

Copy link

kmlucy commented Apr 16, 2018

@danielquinn No worries. My way works for me just fine, it just isn't very portable. If somebody figures out a cleaner way to do it, that's great, but no rush from my end. I looked into it a little, but it's outside my abilities.


This comment has been minimized.

Copy link

apiontek commented Sep 2, 2018

I'm not using docker as in #353 but I am using gunicorn with a unix socket, with paperless-2.1.0

I was able to get this working up to a point. I have:


And my nginx proxy code is:

# paperless
location /papers {
    proxy_pass http://unix:/tank/srvdata/paperless/paperless.sock;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
location /papers/static {
    autoindex on;
    alias /tank/srvdata/paperless/paperless-2.1.0/static;

This works for loading the site and signing in. However when I add my first document, it won't load thumbnails. I get 404 errors on

I tried setting PAPERLESS_MEDIA_URL="/papers/media/" in case that was needed but it didn't fix the issue; I'm not clear what that setting is for or how to use it.

I tried the PAPERLESS_MEDIA_URL along with adding the following to nginx:

location /papers/media {
    autoindex on;
    alias /tank/srvdata/paperless/media;

Still no luck, though that was just guesswork. Any ideas?

EDIT TO ADD: with the above configuration the django error on directly trying to access is:

Using the URLconf defined in paperless.urls, Django tried these URL patterns, in this order:

^fetch/(?Pdoc|thumb)/(?P\d+)$ [name='fetch']
^push$ [name='push']

The current path, papers/fetch/thumb/1, didn't match any of these.


This comment has been minimized.

Copy link

massaquah commented Sep 8, 2018

I am trying to solve this, too.

Any news here?


This comment has been minimized.

Copy link

danielquinn commented Sep 9, 2018

The blocker/solution appears to be #353, as it's most of the way there, but there's still a problem with the handling of static files. I'm afraid I have no idea how to solve it, but if someone can come up with a solution that I can reproduce, I'll gladly merge it.

@ovv ovv referenced this issue Nov 3, 2018


Apache SSL conf #434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.