tobybatch / kimai2

Docker containers for the kimai2 web application including docker-compose and kubernetes/helm deployment.
MIT License
183 stars 96 forks source link

[BUG] invoices are not shown - timesheet entries are not shown in calender #61

Closed AlxBe closed 4 years ago

AlxBe commented 4 years ago

Describe the bug I implemented the kimai2 docker infrastructure based on your docker images/builds. Thank you for that. To access the containers I implemented a nginx reverse proxy in front of it (see docker-compose.yml and app.conf - the nginx proxy conf). Everything works fine (export - all variations) except the invoice generation. The invoice generation does nothing (calls "https://zeit.xxxxxx.de/en/invoice/?searchTerm=&daterange=2020-01-01+-+2020-01-31&customer=1&project=&activity=&tags=&exported=5&template=1&preview=") but nothing appears, no DOCX is downloaded. Btw. the calender doesn't show any timesheet entry, but is displayed correctly

Thank you for your help.

To Reproduce

Desktop (please complete the following information):

Command used to run the container

Docker compose file (with passwords redacted)

version: '3.5'
services:

  sqldb:
    image: mysql:5.7
    environment:
      - MYSQL_DATABASE=kimai
      - MYSQL_USER=kimaiuser
      - MYSQL_PASSWORD=kimaipassword
      - MYSQL_ROOT_PASSWORD=changemeplease
    volumes:
      - /var/lib/mysql
    command: --default-storage-engine innodb
    restart: unless-stopped
    healthcheck:
      test: mysqladmin -pchangemeplease ping -h localhost
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3 

  nginx:
    build: compose
    ports:
      - 8001:80
    volumes:
      - ./nginx_site.conf:/etc/nginx/conf.d/default.conf
    restart: unless-stopped
    depends_on:
      - kimai
    volumes:
      - public:/opt/kimai/public
    healthcheck:
      test:  wget --spider http://nginx/health || exit 1 
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3 

  kimai:
    image: kimai/kimai2:fpm-alpine-1.5-prod
    environment:
      - APP_ENV=prod
      - TRUSTED_HOSTS=*,nginx,zeit.xxxxxxxxx.de
      - ADMINMAIL=admin@kimai.local
      - ADMINPASS=changemeplease
    volumes:
      - public:/opt/kimai/public
      - var:/opt/kimai/var
    restart: unless-stopped
    healthcheck:
      test: wget --spider http://nginx || exit 1
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3

  postfix:
    image: catatnight/postfix
    environment:
      maildomain: neontribe.co.uk
      smtp_user: kimai:kimai
    restart: unless-stopped
    restart: always

  nginx-frontend:
    image: nginx:1.15-alpine
    ports:
      - '80:8000'
      - '443:443'
    volumes:
      - ./nginx-proxy/nginx:/etc/nginx/conf.d
      - ./nginx-proxy/nginx/www:/var/www/zeit.xxxxxxx.de
      - ./nginx-proxy/certbot/conf:/etc/letsencrypt
      - ./nginx-proxy/certbot/www:/var/www/certbot
    depends_on:
      - nginx
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

  certbot:
    image: certbot/certbot
    volumes:
      - ./nginx-proxy/certbot/conf:/etc/letsencrypt
      - ./nginx-proxy/certbot/www:/var/www/certbot
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"

volumes:
    var:
    public:

Additional context kimai container starts with a warning: NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library 'ldap.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/ldap.so (Error loading shared library libldap-2.4.so.2: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20180731/ldap.so)), /usr/local/lib/php/extensions/no-debug-non-zts-20180731/ldap.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20180731/ldap.so.so: No such file or directory)) in Unknown on line 0 nginx proxy config

server {
    listen 80;
    server_name zeit.xxxxxxxxx.de;    
    location / {
        return 301 https://$host$request_uri;
    }    
    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }
}
server {
    listen 443 ssl;
    server_name zeit.xxxxxx.de;

    ssl_certificate /etc/letsencrypt/live/zeit.xxxxxxxx.de/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/zeit.xxxxxx.de/privkey.pem;    

    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    server_tokens           off;
    server_name_in_redirect off;
    ignore_invalid_headers  on;
    if_modified_since       before;
    ssi                     on;
    ssi_silent_errors       on; # testing=off
    add_header X-Frame-Options SAMEORIGIN;
    add_header Strict-Transport-Security max-age=16000000; 

    ### tcp ###
    tcp_nodelay             off;
    tcp_nopush              on;
    sendfile                on;
    keepalive_requests      100;

    ### timeouts ###
    resolver_timeout        6;
    client_header_timeout   30;
    client_body_timeout     60;
    send_timeout            60;
    keepalive_timeout       65 20;

    ### buffers ###
    client_header_buffer_size   1k;
    client_body_buffer_size     128k;
    large_client_header_buffers 4 4k;
    client_max_body_size        10m;
#    client_body_temp_path       /var/spool/nginx/client/;
    output_buffers              1 32k;
    postpone_output             1460;

    ### proxy-buffers ###
    proxy_buffering         on;
    proxy_buffer_size       8k;
    proxy_buffers           256 8k;
    proxy_busy_buffers_size    64k;
    proxy_temp_file_write_size 64k;

    ### proxy-global ###
    proxy_intercept_errors  on; # testing=off
    proxy_ignore_client_abort off;
    proxy_redirect          http:// $scheme://;

   location / {
    proxy_pass http://nginx:80;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header Host $host;
        # Adds the required header for SSL Offloading
    proxy_set_header X-Forwarded-Proto $scheme;
    }

} 
tobybatch commented 4 years ago

I will take a look but this may be an issue for kimai app itself,

stevenhrabok commented 4 years ago

Hi @tobybatch, I'm experiencing the same issue (when preview or print invoice).

I attempted to look at the kimai and nginx container logs and it seems we only see HTTP 200's. When I click Preview I get http://mykimaihost:8001/en/invoice/?searchTerm=&daterange=2020-01-01+-+2020-01-31&customer=1&project=1&activity=1&users%5B%5D=1&tags=&exported=1&template=1&preview= When I do print I get http://mykimaihost:8001/en/invoice/?searchTerm=&daterange=2020-01-01+-+2020-01-31&customer=1&project=1&activity=1&users%5B%5D=1&tags=&exported=1&template=1&create=

When searching Kimai Github Issues, I'm not seeing any bug reports regarding this issue. Is there anything I can provide to assist to find the source of the problem?

kevinpapst commented 4 years ago

@stevenhrabok can you please test some POST forms (edit/create something). Do they work? Now test some forms that utilize GET parameter (eg. search, invoice, pagination). Do they work? I'd say #66 is related.

tobybatch commented 4 years ago

@Schrolli91 have you time to look at this? It could be nginx an forwarding issue, and I'm slammed at work right now.

stevenhrabok commented 4 years ago

@tobybatch Found the fix, attempted to submit a branch with PR, but didn't have permission.

https://github.com/tobybatch/kimai2/blob/master/compose/nginx_site.conf#L14

needs to be changed to try_files $uri $uri/ /index.php$is_args$args;

the missing $is_args$args was causing the uri arguments to be lost.

kevinpapst commented 4 years ago

@stevenhrabok awesome, nice finding! I looked through it, but didn't spot it. FYI - you have to fork the repository, then create the branch, do your changes, push the branch. Now you can create a PR

Bildschirmfoto 2020-01-16 um 17 16 57
tobybatch commented 4 years ago

Top work, thanks you. I'll get that fix in place over the weekend

Schrolli91 commented 4 years ago

ok - I'm too late :-D @stevenhrabok thank you for your investigations

AlxBe commented 4 years ago

Perfect! Thank you very much.

tobybatch commented 4 years ago

@Schrolli91 Can you fix this please? I'm a nginx n00b and I can seem to get it to work.

Schrolli91 commented 4 years ago

@stevenhrabok can you please take a look at the PR #71

atm i'm not able to test these changes properly - should be confirmed before we'll merge this to the master branch

Schrolli91 commented 4 years ago

closed because PR is on the way