question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Horror with Docker & Reverse Proxy because of all the paths

See original GitHub issue

hey guys, it’s very hard to configure a reverse proxy with docker because nearly every function in papermerge has it’s own path (/upload/, /static/, /nodes/ etc.). It’s even harder if you are running other apps that shares a path with papermerge like /upload/.

My Apache Config looked like:

ProxyPass /papermerge/ http://127.0.0.1:8000/ retry=0
ProxyPassReverse /papermerge/ http://127.0.0.1:8000/

ProxyPass /alltags/ http://127.0.0.1:8000/alltags/ retry=0
ProxyPassReverse /alltags/ http://127.0.0.1:8000/alltags/

ProxyPass /automate/ http://127.0.0.1:8000/automate/ retry=0
ProxyPassReverse /automate/ http://127.0.0.1:8000/automate/

ProxyPass /breadcrumb/ http://127.0.0.1:8000/breadcrumb/ retry=0
ProxyPassReverse /breadcrumb/ http://127.0.0.1:8000/breadcrumb/

ProxyPass /browse/ http://127.0.0.1:8000/browse/ retry=0
ProxyPassReverse /browse/ http://127.0.0.1:8000/browse/

ProxyPass /upload/ http://127.0.0.1:8000/upload/ retry=0
ProxyPassReverse /upload/ http://127.0.0.1:8000/upload/

...

And some functions still doesn’t work. Best solution would be a top-level path like /papermerge/ and then sub-paths for all other functions. This makes Reverse-Proxy configs very easy with 2 lines like this:

ProxyPass /papermerge/ http://127.0.0.1:8000/papermerge/ retry=0
ProxyPassReverse /papermerge/ http://127.0.0.1:8000/papermerge/

I have tested this with many other apps, some of them support Docker Environment Variables to configure this path.

regards

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
whysthatsocommented, Dec 19, 2020

i’m curious why you encounter these problems. are you trying to run an apache2 instance infront of the running container setup? or are you trying to replace the apache2 instances inside the docker-compose setup as it’s being run as an application server via mod_wsgi-express? in the latter case i don’t know, in the former case i’m not sure why you would need all these routes?

tbh i don’t know the apache setup, the corresponding nginx vhost for my setup looks like that:

  upstream papermerge_server {
    server app.example.net:42551 fail_timeout=0;
  }

  server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name papermerge.example.net;
    
  <snip ssl stuff>

    client_max_body_size 20M;
    keepalive_timeout 5;
    root /var/www;
    try_files $uri/index.html $uri.html $uri @app;

    location @app {
      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;
      proxy_pass http://papermerge_server;
    }

}

1reaction
whysthatsocommented, Jan 20, 2021

i understand your use case, of course. just for sake of completeness:

  • letsencrypt offers wildcard certificates
  • one would probably prefer cname records over a records, but that depends on the underlying infrastructure

and - of course - one avoids a bunch of “horrible” routing issues 😄

but i do acknowledge that there are different scenarios.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reverse Proxies with Nginx Proxy Manager
In this article, we will: Deploy Nginx Proxy Manager as a reverse proxy manager; Show how to reverse proxy docker services, as well...
Read more >
Problem with nginx reverse proxy and docker. Only one ...
The idea being to have proxy routes to different projects in docker environments and provide https for all of them/their services. So the...
Read more >
Docker reverse proxy using Traefik | Accesto Blog
Common approach to reverse proxy servers in Docker ... Traefik also supports other matchers, f.e. path, but we will take a look at...
Read more >
How to handle HTTPS using Nginx, Let's encrypt and Docker
This post will guide you through a step-by-step process to protect your website (and your users) using HTTPS in a docker environment.
Read more >
How to set up an easy and secure reverse proxy with Docker ...
by Kasper Siig Introduction Ever tried setting up some sort of server at home? Where you have to open a new port for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found