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

Configuration for reverse proxy #66

Open
bformet opened this issue Dec 20, 2019 · 4 comments
Open

Configuration for reverse proxy #66

bformet opened this issue Dec 20, 2019 · 4 comments

Comments

@bformet
Copy link

bformet commented Dec 20, 2019

Hey 👋, at ESRF beamlines we would like to be able to run multivisor behind a nginx reverse proxy at some specific location.

The nginx config would look like:

    location /multivisor/ {
            proxy_pass http://localhost:22000/;
    }

Thus we would need multivisor ressources to be relative to current path instead of absolute, and/or to have an option to configure the relative webapp root path, like:

  -r, --relative-root         string         webapp relative root (default "/")

Thanks for the great work

@tiagocoutinho
Copy link
Owner

Makes sense to me.
Would you be willing to work on a PR?
I am not sure what is the best solution. I guess I prefer a solution that did not involve an extra command line option but if you think it is the best way to go, it is fine by me.

@iwzd520
Copy link

iwzd520 commented Mar 11, 2020

location ^~ /supervisord/
{
proxy_pass http://10.195.14.6:22000/;
}

I have these question, too , I use it behind a nginx proxy. Because I only have one DNS,so Imust use the location path .
The static file can,t access,error code 404.

there is Elastic Kibana manual,it hava some describe about use proxy.Maybe we can refer to.

server.basePath:
Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests to Kibana. This setting cannot end in a slash (/).

https://www.elastic.co/guide/en/kibana/5.5/settings.html

@kratsg
Copy link

kratsg commented Nov 3, 2022

I've managed to do this with a custom Dockerfile with some quick sed work that seems to work well (using traefik as a reverse-proxy):

$ cat multivisor/Dockerfile 
FROM python:3
# last few sed commands needed to run under reverse proxy correctly
# see: https://github.com/tiagocoutinho/multivisor/issues/66
RUN python -m venv venv && \
    . ./venv/bin/activate && \
    python -m pip install -U pip multivisor[web] 'werkzeug<2.1.0' 'flask==2.1.3' && \
    sed -i 's|=/static|=static|g' venv/lib/python3.11/site-packages/multivisor/server/dist/index.html && \
    sed -i 's|"/api|"api|g' venv/lib/python3.11/site-packages/multivisor/server/dist/static/js/*.js


COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["--bind", "0.0.0.0:22000", "-c", "/multivisor.conf"]

and my entrypoint.sh looks like

$ cat multivisor/entrypoint.sh 
#!/bin/sh
set -e

set -- /venv/bin/multivisor "$@"

echo "$@"
exec "$@"

Ideally, one would mount to /multivisor.conf in this example, but as you can see, it's only a few sed replacements to make it work correctly (dropping the absolute path).

EDIT: Doesn't quite work because the Vue app does some routing as well, and that starts breaking more things...

@daydaychen
Copy link

It's my solution:

  1. replace path, add prefix
sed -i 's|/static|/multivisor/static|g' /.venv/lib/python3.10/site-packages/multivisor/server/dist/index.html && \
sed -i 's|/api|/multivisor/api|g' /.venv/lib/python3.10/site-packages/multivisor/server/dist/static/js/*.js && \
sed -i 's|path:"/|path:"/multivisor/|g' /.venv/lib/python3.10/site-packages/multivisor/server/dist/static/js/*.js && \
sed -i 's|to:"/|to:"/multivisor/|g' /.venv/lib/python3.10/site-packages/multivisor/server/dist/static/js/*.js
  1. add nginx conf
    location /multivisor {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        rewrite          ^/multivisor/(.*)$  /$1  break;
        proxy_pass http://localhost:22000;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants