linuxserver / docker-grocy

A container for grocy - the ERP application for your kitchen https://grocy.info
GNU General Public License v3.0
333 stars 44 forks source link

Grocy erorr behind reverse proxy "Error While Saving" #18

Closed t3pfaffe closed 4 years ago

t3pfaffe commented 4 years ago

linuxserver.io


I originally put this in https://github.com/grocy/grocy but was told to post it here instead

Expected Behavior

Reloading does not result in an error and the settings menu is able to change

Current Behavior

Changing anything in settings does not result in an actual change (I think changing users still works) On reload error message Error while saving, probably this item already exists \n Click to show technical details. When clicking it for more details it responds with "\r\n\r\n\r\n 405 Not Allowed \r\n nginx/1.16.1 \r\n\r\n\r\n"

Using this nginx reverse proxy config:

# Grocy ReverseProxy Config
# @author <redacted> 03/25/20

upstream grocy_backend {
    server 10.0.0.122:9283;
}

server {
    listen       443;
    listen  [::]:443;
    server_name  grocy.<redacted>.me;

    #Include default parameters
    include /usr/local/etc/nginx/conf.d/template_configs/server.default.conf;
    include /usr/local/etc/nginx/conf.d/template_configs/server_ssl_cloudflare.default.conf;

    location / {
        proxy_pass http://grocy_backend;
    }
}

Steps to Reproduce

  1. Docker pull /linuxserver/grocy
  2. Access the web server from behind a reverse proxy using the configuration above
  3. Observe error message appear in top left corner on each reload
  4. Attempt to change any of the settings and observe nothing change

Environment

OS: RancherOS
CPU architecture: x86_64
How docker service was installed: Portainer with docker run (all env left to default)

Command used to create docker container (run/create/compose/screenshot)

(Through portainer) its a docker pull with 9283:80 ## Docker logs
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing... 
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 10-adduser: executing... 
usermod: no changes

-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \ 
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    911
User gid:    911
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing... 
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing... 
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 50-config: executing... 
[cont-init.d] 50-config: exited 0.
[cont-init.d] 99-custom-files: executing... 
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
gaiacanon commented 4 years ago

Also getting this error when using Grocy through Docker-Compose behind Traefik.

For example, if I try making a new task, I get the error:

Error while saving, probably this item already exists

Click to show technical details

If I click it, I get the error:

Error details
""

So I think that grocy isn't seeing any text in the fields for some reason.

I've tried using Chromium-Edge as well as regular old Chrome and get the same error in both.

t3pfaffe commented 4 years ago

The reason causing this in my particular case was found. I had a nginx config that only allowed a few http methods (GET | HEAD | POST) for security reasons surrounding TRACE and DELETE. I assume grocy is using more than those 3 so once I removed the method whitelist the issue dissapeared. @gaiacanon I would check for similar HTTP method whitelists in Trafeik.

inhji commented 3 years ago

In my case the error was resolved by adding this line to my nginx config:

proxy_set_header X-Forwarded-Proto https;