jonaswinkler / paperless-ng

A supercharged version of paperless: scan, index and archive all your physical documents
https://paperless-ng.readthedocs.io/en/latest/
GNU General Public License v3.0
5.37k stars 355 forks source link

Running webserver e.g. nginx #72

Closed acrimat closed 3 years ago

acrimat commented 3 years ago

Dear Dev,

I'm just wondering how would I use nginx with paperless-ng?

Steps I tried with default, unmodified settings (docker-compose.yml):

  1. collect statics:

    cd /to/paperless
    docker-compose down
    docker-compose run --rm webserver collectstatic

    ... You have requested to collect static files at the destination location as specified in your settings: /usr/src/paperless/static This will overwrite existing files! Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel:

    yes

    0 static files copied to '/usr/src/paperless/static', 187 unmodified.

  2. install and configure nginx

    apt install -y nginx
    nano /etc/nginx/sites-available/default

    server { listen 80;

    index index.html index.htm index.php; access_log /var/log/nginx/paperless_access.log; error_log /var/log/nginx/paperless_error.log;

    location /static {

    autoindex on; alias /usr/src/paperless/static;

    }

    location / {

    proxy_set_header Host $http_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;

    proxy_pass http://127.0.0.1:8000; } }

I can navigate to http://[host-ip]:8000 When I navigate to http://[host-ip] (port 80) I get a white page which states Loading...

tail /var/log/nginx/paperless_error.log

[error] 17600#17600: 2 open() "/usr/src/paperless/static/frontend/__[files] __" failed (2: No such file or directory)

[files] *: multiple files stated, e.g. styles.css, runtime.js, polyfills.js ...

What am I doing wrong? Any tips are appreciated. Thanks in advance for your time!

jonaswinkler commented 3 years ago

The only thing I had to do was to setup

location / {
  proxy_pass http://localhost:8000/
}

and that's about it.

When using docker, keep in mind that all files of paperless are stored inside the image. They are not accessible on the host. The collectstatic step will collect files inside the image and store them inside the image, which has already been done. The webserver that serves the wsgi application of paperless also serves the static files, so there's no need to do anything fancy with that.

If you wish to do any more than that, you have to install paperless without docker.

Also, please keep in mind that serving paperless on a sub URL isn't currently supported, there's some issues with the assets of the front end. See #36.

If this answers your questions, please close the issue.