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 doccano in a subpath #1878

Open
aisensiy opened this issue Jun 27, 2022 · 3 comments · May be fixed by #2008
Open

Deploy doccano in a subpath #1878

aisensiy opened this issue Jun 27, 2022 · 3 comments · May be fixed by #2008
Labels
enhancement Improvement on existing feature

Comments

@aisensiy
Copy link

I know this is an old issue. But after some attempts I still failed to deploy doccano under some subpath.

And I know there is another label tool named Label Studio, it supports subpath by command like this:

$ label-studio --host https://example.com/by/subpath/of/label-studio

So I just read its code and try to change the FORCE_SCRIPT_NAME in doccano but seems not working.

https://github.com/heartexlabs/label-studio/blob/70f12eb96860709bb53c10bf1aa9e1257adef166/label_studio/core/settings/base.py#L45

Here is some attemp I did:

aisensiy@66b87e4

I really want to make doccano support the subpath. Hope some one give some tips about this.

My Environment

  • Operating System: Mac OS 12.4 M1
  • Python Version Used: 3.8
  • When you install doccano: June 24
  • How did you install doccano (Heroku button etc): pip install doccano

Related issues:

@Stifo
Copy link

Stifo commented Jul 8, 2022

Hello, I was trying to achieve the same using Docker compose with my nginx webserver and got it work by doing following:

Doccano

  1. in frontend/nuxt.config.js, set base to your subpath
...
export default {
  router: {
    base: '/mysubpath/'
  },
...

and set baseUrl from /v1 to /mysubpath/v1:

...
   env: {
    baseUrl: '/mysubpath/v1'
   },
...
  1. rebuild the image and run:
docker-compose -f docker/docker-compose.prod.yml up --build
  1. Configure conf.d/default.conf of my nginx webserver, not the one that comes with doccano's docker-compose.prod.yml:
    location /mysubpath/ {
        proxy_pass          http://doccano-nginx:8080/;
        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;
    }

where doccano-nginx is the name of the nginx container in docker/docker-compose.prod.yml

Django's admin area:

  1. change STATIC_URL from /static/ to /mysubpath/static/ in backend/config/settings/base.py:
...
STATIC_URL = "/mysubpath/static/"
...
  1. add following settings to backend/config/settings/production.py:
USE_X_FORWARDED_HOST = True
FORCE_SCRIPT_NAME = '/mysubpath/'

@Hironsan Hironsan added the enhancement Improvement on existing feature label Jul 13, 2022
@mkmark
Copy link
Contributor

mkmark commented Jul 29, 2022

Hello, I was trying to achieve the same using Docker compose with my nginx webserver and got it work by doing following:

I run under python env and I have to additionally add the prefix to all urlpatterns in backend/config/urls.py

# Add 'prefix' to all urlpatterns
if settings.URL_PREFIX:
    urlpatterns = [path(f'{settings.URL_PREFIX}/', include(urlpatterns))]

and in backend/config/settings/base.py add

URL_PREFIX = "mysubpath"

Otherwise, I cannot log in.
Not sure if I miss anything else.

reference https://stackoverflow.com/a/56639722/18672686

@Vinno97 Vinno97 linked a pull request Sep 19, 2022 that will close this issue
@oplatek
Copy link

oplatek commented Dec 30, 2022

Having this issue solved would be immensely useful for me.
I am working in a university environment where the URL for requests looks like public.path.com/machine-name/user-name/.
Using Apache reverse proxy rules I can preserve the URL when binding doccano to localhost.

ProxyPass my-name/doccano http://127.0.0.1:8090/my-name/doccano
ProxyPassReverse my-name/doccano http://127.0.0.1:8090/my-name/doccano

I hoped to apply tutorial on how to mount flask to subpath using gunicorn also for doccano but I am confused how doccano uses wsgi and how can I influence the django URL settings in doccano?

Can wsgi and gunicorn be used to easily run doccano with subpath? If yes, how?

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

Successfully merging a pull request may close this issue.

5 participants