PhiTux / DailyTxT

Encrypted Diary Web-App
https://hub.docker.com/r/phitux/dailytxt/
MIT License
208 stars 14 forks source link

Reverse proxy with subpath doesn't work #36

Open alpe12 opened 1 year ago

alpe12 commented 1 year ago

The login page appears fine here on my subpath. But the login doesn't work. It tries to send a request to "/api/login" and not "/mysubpath/api/login". Maybe the /api part is out of this fix?

Originally posted by @alpe12 in https://github.com/PhiTux/DailyTxT/issues/2#issuecomment-1674165712

PhiTux commented 1 year ago

Hi @alpe12,sorry for the late reply, I also read your comment on the old issue.Sadly, I will not be able to address this issue within the next few weeks, since I'm now on holiday and support for DailyTxT is reduced now. I still hope, that the other guy from the old commit might answer your comment...

gardiol commented 3 months ago

Hi! I have the same issue. I think, by looking at the @rhld16 contribution, that's only mnatter of specifying some header in NGINX configuration file, but it's unclear to me what that would be.

I hope somebody can shine some light on the topic as it would be very appreciated. (pinging @PhiTux and @rhld16)

That info should be added to the README.md.

gardiol commented 3 months ago

Update: according to , it seems that @rhld16 made this setting relative, which means that it should work with any subpaths you are throwing at it. At this point, i think it's mostly an wrongly configured NGINX proxy in my case, i will experiment and report a working config, if i find it.

gardiol commented 3 months ago

I am giving up because i cannot find a working solution. I can get the container receive the proper subpath, but the server is still rpelying with https://mydomain.com/api/register without the subpath. I might try some rewrite rules on the reverse proxy maybe, but it shouldn't be needed?

PhiTux commented 3 months ago

Hey @gardiol,

I'm sorry to hear, that subpaths are still making problems.

I now looked into the problem and it should now be fixed (new release 1.0.15). The frontend is now aware of the path and can adapt the /api calls.

Please test it and give feedback.

gardiol commented 3 months ago

I have just updated my docker images and still i have some issues. It seems now frontend manages the subpath properly (since now i get https://mydomain.com/dailytxt/api/register as a reply when i hit "register" button) but now i get a 405 Not Allowed as reply.

This is my docker compose:

version: "3"

services:
  dailytxt:
    image: phitux/dailytxt:latest
    container_name: dailytxt
    restart: always
    environment:
      - PORT=8760
      - SECRET_KEY=<mysecret>
      - ALLOW_REGISTRATION=True
      - DATA_INDENT=2
      - JWT_EXP_DAYS=6000
      - ENABLE_UPDATE_CHECK=True
    ports:
      - "127.0.0.1:8760:8760"
    volumes:
      - "/mypath/dailytxt/:/app/data/"
    networks:
      - dailytxt-net

networks:
  dailytxt-net: {}

And this is my relevant nginx config (reverse proxy):

location = /dailytxt {  
        return 301 https://$host/dailytxt/;
}

location /dailytxt/ { 
        proxy_pass        http://127.0.0.1:8760;
}

the error comes from the NGINX inside the container, not my reverse proxy (i know, because version is different).

PhiTux commented 3 months ago

Sadly I've no nginx to test it out. It worked with apache2 for me.

gardiol commented 3 months ago

I doubt NGINX is in any way involved here, the 405 comes from the python... it's only relayed by the NGINX because that's what the container uses as proxy.