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
403 CSRF Error (AGAIN) #518
Comments
please try setting Other than that the issue is most likely related to certain headers not being forwarded by nginx-proxy manager but i dont really know which ones that would be. Please try * and tell me if it works, if not we will have to further investigate this issue. |
Thanks, will test soon. I have the same theory, the nginx proxy manager is surely missing some headers. The funny thing is I have another working setup which is standard nginx > Recipes web app This nginx container is using the standard config from Linux server SWAG and such config does not add any header, it's a simple config + /media mapping for images. I'll keep you posted, I've also tested some headers but I can't remember which. |
Hey, Thanks! |
what does the broken image show as an url ? (right click copy address) The image url is determined by django by the URL the application is running under. This itself is received trough the headers from the proxy (as far as i know). Sadly there are just so many ways to configure this application to run that i cant tell you for each specific one why its not working. @chrisklpp have you tried using |
I tried |
and both options give you a CSRF error ? Could you please provide a structured explanation of you setup with the different services and configurations used for each service ? |
Yes both options return the CSRF error in Chrome, Firefox and Safari, the following error message is shown: As said it works when the port 443 is used and when I access it locally on The nginx installation is used for multiple selfhosted services, that all work fine on the 444 port (e.g. Seafile, Bitwarden via docker-compose, home-assistant). This is the used configuration for the recipes subdomain: I installed it following the guide in the documentation with docker-compose with the following configuration files: I tried it with multiple variations for the lines Thanks for looking into it. |
ok thanks for the info. I will try to look into this in the next few days, maybe it is time to add some kind of variable to define the application URL or something |
Hi, I had the same issue and fixed it. Look into your nginx config if you have something like: proxy_set_header Host $host:$server_port; change it to: proxy_set_header Host $http_host; and it will work |
Thanks for the feedback @Nicras if @chrisklpp and @auanasgheps could quickly report back if this worked after testing that would be great |
Thank you @Nicras, the solution works for me! And thank you @vabene1111 for the help and the amazing software. |
Me and @auanasgheps should be able to try tomorrow. |
Hi guys, Adding I believe this happens because by default it applies So we're hitting a "limit" of this application and don't really know how to proceed. Any help is appreciated. EDIT: I managed to temporarily edit the file and the config works resolving the issue, but it's not persistent since it's not an exposed file. Either way this value should be added to the docs! |
thanks for the feedback. I have never worked with nginx proxy manager and i am interested to see what the people who maintain it, who most likely know a lot more about this stuff than i do, have to say to this issue. How do you think would this best fit into the docs ? Should we add a section for nginx proxy manager specifically or maybe some FAQ with CSRF errors 🤔 The problem here for me is that i do not fully understand how this works yet so a little uncertain right now. |
I could imagine a nginx sites-available/recipes.conf template could be useful as a part of the installation docs. I would assume many users have a seperate nginx installation managing the different selfhosted services with subdomains. |
I think you should add something like this, please adjust the wording since I'm writing from mobile If you plan to access Recipes via an additional Nginx reverse proxy (e.g. You have a main nginx proxy exposed to the internet)
Nginx Proxy Manager apparently does not allow for this change, therefore it doesn't work (link to this issue) |
there are many different reverse proxy systems, when using the jwidler nginx proxy or traefik this change is NOT required so we need to list it as only required for Nginx Proxy manger right ? @chrisklpp are you using just a default nginx as the reverse proxy ? Then the docs should probably say something like "when using any other nginx based proxy (not jwidler/traefik which i both tested) make sure to set |
I think this configuration is required with swag by linuxserver as well. Let me check my other setup. |
yes that is likely, i remember people had problems there as well |
Yes, I use the default nginx that comes with Ubuntu Server (or is installed with aptitude) |
Uhm, swag by linuserver requires a different config, which is If I use If I don't use any of those, I get a CSRF error. |
i have added some information about this in the new faq section of the docs (not yet pushed) |
Hi, Setting the value to |
I am a bit puzzled with that. I use Cloudflare->NGINX Proxy Manager->Local Service for many services, but for Tandoor I get the CSRF error after logging in. Now I get that I cannot solve that issue in NGINX Proxy Manager, but where and how in my docker stack would I now add this proxy_set_header statement? Can I just add this as an environment variable or how is it to be done? |
As I said:
I do not use this software so I can't provide more instructions. I posted this on behalf of a friend, he ended up using the nginx version I use (swag by linuxserver) with the modifications I mentioned. |
As I am not able to resolve tha with my current capabilities:
this is the CSRF mechanisam from Django. As per https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-CSRF_TRUSTED_ORIGINS or https://stackoverflow.com/questions/75704235/django-csrf-verification-failed-request-aborted-in-production-without-domain I understand that it probably is necessary to put my origin domain as CSRF_TRUSTED_ORIGINS or completely disable the CSRF check. Would it be possible to have both options via environment variables? |
You can set CSRF_TRUSTED_ORIGINS env variable and Tandoor will use it. However, it is very unlikely that this is the root of your issue. Tandoor isn't doing anything that would trigger cross site scripting. Can you please share the headers that are listed on the 'system' page? |
Thanks for pointing that out, I did not know that this env variable is considered (not included in the .env template, and in an old post I read that it is not implemented yet #409 (comment)). Putting my exact URL into the CSRF_TRUSTED_ORIGINS allows login without any CRF error anymore! :-) But now the next problem occurs. After logging in, no recipes are displayed, just placeholders (I do see the recipes when I access via internal IP address): This is what I see in the debug log: SERVER_PROTOCOL:HTTP/1.0 HTTP_HOST:rezepte.mydomain.de wsgi.errors:<gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f43ea926680> Is this an http/https problem? |
Can you please open a new issue- your issue is different than the original. |
Issue
Hi, I'm trying to use Recipes with Nginx proxy manager using the following setup:
Nginx Proxy Manager > Recipes Nginx > Recipes Web App
I've configured Recipes Nginx using the provided config file and in fact works good.
When I connect in LAN pointing to Regipes Nginx everything works good (photos included).
However if I configure Nginx Proxy Manager to point to Recipes Nginx, nobody is able to login.
I believe there's something missing in Nginx Proxy Manager, but I can't figure it out. I also tried connecting straight to the Recipes Web app (exposing the port) but still getting the same error.
Enabling debug, the web browser shows
Setup Info
Version: 0.14.5
OS: Synology NAS w/ Docker
Other relevant information regarding your problem (proxies, firewalls, etc.)
.env
Please include your
.env
config file (make sure to remove/replace all secrets)I added my domain to
ALLOWED_HOSTS
docker-compose.yml
When running with docker compose please provide your
docker-compose.yml
Logs
From Docker - Recipes Web App:
[2021-04-03 15:16:33 +0000] [14] [INFO] Booting worker with pid: 14
Forbidden (Referer checking failed - https://recipes.mydomain.cloud:8080/accounts/login/?next=/search/ does not match any trusted origins.): /accounts/login/
The text was updated successfully, but these errors were encountered: