nginx reverse proxy folder 403 error

I am running nginx as reverse proxy directly installed on the server. To access different webapps I am using sub folders. Two webapps are running in docker containers (pydio and cops).

For pydio this location commands are working; same one for cops is not working.

  • multiple SLF4J bindings on maven run in docker
  • Docker Image Requirements for a GitLab-CI Runner
  • docker-compose build error ubuntu mango
  • HHVM inside Docker always running as root
  • gunicorn fails to launch python-eve
  • Custom Docker Bridge w/ Fedora 22
  •    location ^~ /pydio {
        client_max_body_size 20G;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
        send_timeout 300;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:82;
        proxy_redirect off;
    }
    

    I tried different settings found by searching – none worked.

    This is the latest version which results in a 403 error:

       location ^~ /ebooks(.*)$ {
        client_max_body_size 1G;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
        send_timeout 300;
        rewrite ^/ebooks(/.*)$ $1 break;
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://192.168.100.67:83$1/;
        proxy_redirect off;
        autoindex on;
    }
    

    And this entry in my error.log:

    [error] 29235#29235: *1 directory index of “/var/www/ebooks/” is forbidden, client: 87.174.111.111, server: myadress.de, request: “GET /ebooks/ HTTP/1.1”, host: “myadress.de”

    When I hit 192.168.100.67:83 directly in my browser everything is working fine.

    The folder /var/www/ebooks has www-data:www-data and 750 rights and it is linked with the container by the running command:

    docker run ... -v /var/www/ebooks:/config … according to this https://hub.docker.com/r/lsioarmhf/cops/

    Hope I made my problem clear and you will help me. Thanks

  • graphql and serverless offline running in docker
  • Running Docker on Mac, build works, run errors: : /bin/sh: 1: [: missing ]
  • Docker for ruby on rails app
  • karma phantomjs not capturing in docker container
  • How to run Tensorboard and jupyter concurrently with docker?
  • Acceptance testing, docker and selenium
  • One Solution collect form web for “nginx reverse proxy folder 403 error”

    good an bad news.

    After testing a little more I found setting passing the command to docker correctly.

        location ^~ /ebooks {
    
            proxy_connect_timeout 300;
            proxy_send_timeout 300;
            proxy_read_timeout 300;
            send_timeout 300;
            rewrite ^/ebooks(/.*)$ $1 break;
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:83$1;
            proxy_redirect off;
    }
    

    But cops page is only displayed in a basic way (background color changes but matrix not shown)

    This is error log entry:

    an upstream response is buffered to a temporary file /var/lib/nginx/proxy/1/00/0000000001 while reading upstream, client: 11.114.211.38, server: myadress.de, request:: “GET /ebooks/resources/jQuery/jquery-1.11.1..js?v=1.0.1 HTTP/1.1”, upstream: “http://127.0.0.1:83/resources/jQuery/jquery-1.11.1.min.js”, host: “myadress.de”, referrer: “https://myadress/ebooks/”

    To give you a complete picture. This is nginx config of cops container.

        server {
    
        listen 80 default_server;
    #   listen 443 ssl;
        server_name _;
    #   ssl_certificate /config/keys/cert.crt;
    #   ssl_certificate_key /config/keys/cert.key;
        access_log  /config/log/nginx/access_cops.log;
        error_log /config/log/nginx/error_cops.log;
        root   /var/www/localhost/cops;
        index index.php;
    
        #Useful only for Kobo reader
        location /cops/ {
              rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /fetch.php?data=$1&db=$2&type=$3 last;
              rewrite ^/download/(\d+)/.*\.(.*)$ /fetch.php?data=$1&type=$2 last;
              break;
            }
    
            #Can break loading the images - if you don't see anything, comment
            location ~ ^/images.*\.(gif|png|ico|jpg)$ {
                    expires 31d;
            }
            #Can also break loading the images, comment if it happens
            location ~ .(js|css|eot|svg|woff|ttf)$ {
                    expires 31d;
            }
    
        #Not necessarily correct, it depends on distro.
        location ~ \.php$ {
           include /etc/nginx/fastcgi_params;
           fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
           fastcgi_pass    127.0.0.1:9000;
        }
    location /books {
          root /;
           internal;
    }
    }
    

    Any ideas if I am missing something?

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.