http 405 error in frontend when running with traefik v2 and docker #1708
Labels
No Label
dependencies
duplicate
help wanted
invalid
kind/bug
kind/feature
needs reproduction
question
security
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/vikunja#1708
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
No matter what I try in my docker-compose I seem to end up with a 405 error on the front end.
I can reach the frontend, fill out the register form but on submission there is a brief flash of 'loading' and nothing else happens.
Checking the logs for the frontend container I see:
405 is "Method Not Allowed"
As far as I can tell this means that the request is reaching the backend but the backend is refusing to answer for some reason.
The logs on the backend container don't show anything special
Can you reach the info endpoint on the backend?
Try running
Are you using the traefik example from the docs?
If I include the port number I defined in my docker-compose:
I get "We're sorry but Vikunja doesn't work properly without JavaScript enabled" etc.
Which doesn't seem llike 'info'? Visiting that url in the browser gives a TypeError "navigator.serviceWorker is undefined". Actually I get that error on the login and register pages too...
I'm using traefik v2, so not exactly the the example from the docs, no. A conversion of it, also not quite the same as the one given on reddit
I'm adding it to a stack with traefik, portainer and kanboard already present.
Edit: I think the issue may well be in my docker/traefik config. Don't seem to be serving via https correctly.
Could you post your traefik config?
It seems this might be a race condition where the frontend starts faster than the back end and so traefik uses it prefferrably.
I experimented with only starting the backend - no response with curl until I added ports "3456:3456", which makes sense.
Then get a response on:
of
Obviously curl wasn't going to get a response without the backend allowing connection to the outside world? Does the frontend need that too though? I'd assumed the back and front end being on the same 'backend' docker network would be enough...
Still can't register or login once the frontend is started.
I also don't have fully functioning https yet.
Attaching a sanitized docker-compose.yml and the two jinja2 templates I have ansible copy into place for traefik config - mostly just vars for domain name etc. I hope their clear enough.
The requests from the frontend to the backend happen in the browser, so the backend must be reachable from the outside world.
The frontend assumes the backend on
/api/v1
of the same host.Since you're using traefik, you should not need to expose ports of both containers, traefik should handle that.
In your example, you should be able to use Vikunja from
vikunja.app.example.com
(aka get the frontend if you visitvikunja.app.example.com
directly in your browser).You can verify the routing of the backend is working correctly by running
(should return the info response you posted earlier)
I've been able to remove the ports declarations yes - since I already have kanboard on a different port vikunja can use 80/443 (but not specifying a port for multiple services which run on 80 or 443 results in an error when running 'docker-compose up': "port is already allocated").
Still haven't been able to get things functioning though.
Might bring down my whole stack and try with some of the example compose files alone. About ready to throw in the towel though. I don't think it's vikunja's fault so much as my inexperience with docker and traefik.
Do you see the vikunja containers in the traefik backend?
I'll try to put out an example docker-compose configuration with traefik v2 soon, maybe that will work...
This would make sense since traefik already uses these ports to communicate from the outside world.
You also have
traefik.http.services.vikunja-backend.loadbalancer.server.port
in your traefik config, normally you should not need that. Traefik is able to figure out what ports the vikunja docker image exposes and redirect the traffic to that. That should not be an issue here though.You also seem to put the vikunja docker containers in the
web
network, but if I saw that correctly you're never telling traefik to use that network. This may still work though because you have all containers in a single docker-compose file which lets them see each other by default.Did you try increasing the log level of traefik to
debug
to see if it logs anything useful?More progress, somewhat shame faced, realised the the host firewall was blocking access. That's why I setting ports in the docker-compse seemed to be required - it makes docker create firewawll rules in its own iptables chain bypassing the host chains.
I've slimmed down my compose file a bit more removing the loadbalancer lines as you suggested. Also removed most of the 'ports' declarations and reworked the 'networks' declarations.
Traefik debug logs don't seem to show anything else useful.
But I have been able to create an account it vikunja and log in. Unfortunetly I get '404 page not found' errors that prevent vikunja from working properly (no sidebar menu?). My kanboard container also gives '404 page not found' so clearly still have something not quite right in this stack.
Still investigating the 404 errors.
The kanboard 404 errors turned out to be due to a typo in my traefik labels. The vikunja 404 errors not so.
Testing the api with curl I get, using http url:
and with https url:
So it appears that the frontend wants to reach the api on http but traefik is only routing over https as I have it configured.
edit: sanitised docker-compose.yml attached
Found an the error in the api container logs for the 404 - maybe it is routing ok
I don't know what I changed - possibly just adding https to the start of the frontendurl environment variable - created a second account using Chrome instead of Firefox and it worked! Also then worked in Firefox after a browser reload.
Fixed!
The sympthomes you described were a bug in the frontend which I've fixed in
fe6c859150
.Glad it works now!
I think this can be closed.