0

In a Docker container running PHP71-FPM and Nginx I have the following setup for Nginx:

server {
    listen      80  default_server;
    listen      81  default_server http2 proxy_protocol; ## Needed when behind HAProxy with SSL termination + HTTP/2 support
    listen      443 default_server ssl http2;

    ssl_certificate       /etc/nginx/ssl/dummy.crt;
    ssl_certificate_key   /etc/nginx/ssl/dummy.key;

    root        /data/www/demos/jqgrid;
    index       index.php index.html index.htm;

    location ~ \.php$ {
      include         fastcgi_params;
      fastcgi_pass    php-upstream;
    }

    include     /etc/nginx/conf.d/stub-status.conf;
    include     /etc/nginx/conf.d/default-*.conf;
}

Accessing http://localhost shows up the index page but without styles or any JS file loaded. I am not able to find what's is preventing the static files to be accessed.

Here is the output of ls -la command in the host (remember this is a Docker container running PHP-FPM and Nginx):

$ ls -la ~/dev/
total 96
drwxrwxr-x  11     80     80 4096 Dec 15 14:36 .
drwx------. 40 rperez rperez 4096 Dec 15 15:01 ..
drwxr-xr-x   5     80     80 4096 Mar 13  2015 css
drwxr-xr-x   7     80     80 4096 Aug  5  2015 demos
drwxr-xr-x   6     80     80 4096 Mar 26  2015 js
drwxr-xr-x   2     80     80 4096 Mar 27  2015 northwindSQL
drwxr-xr-x   4     80     80 4096 Mar 16  2015 php

The permissions are coming from Docker (weird to me but I have open another post here for that)

This files are from my repository and this ones are from the repository where FROM comes in the Dockerfile.

Can I get some help with this?

Update

As @Michael suggested I have check the Nginx logs on the container and I can see the following:

php71-fpm-nginx | 2016-12-15 20:02:40,483 DEBG 'nginx' stderr output:
php71-fpm-nginx | 2016/12/15 20:02:40 [error] 33#33: *46 open() "/data/www/demos/jqgrid/css/jquery-ui.css" failed (2: No such file or directory), client: 172.20.0.1, server: , request: "GET /css/jquery-ui.css HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
php71-fpm-nginx | 
php71-fpm-nginx | 2016-12-15 20:02:40,830 DEBG 'nginx' stderr output:
php71-fpm-nginx | 2016/12/15 20:02:40 [error] 33#33: *46 open() "/data/www/demos/jqgrid/css/control_icon.png" failed (2: No such file or directory), client: 172.20.0.1, server: , request: "GET /css/control_icon.png HTTP/1.1", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
php71-fpm-nginx | 

But how that can be possible if the code says the opposite?

<script src="../../js/jquery.min.js" type="text/javascript"></script>
<script src="../../js/jquery-ui.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../../css/jquery-ui.css" media="screen" />
ReynierPM
  • 710
  • 5
  • 14
  • 30

1 Answers1

0

Your application has been developed so that your document root has to be:

root /data/www/demos/jqgrid;

And then you would access the application with URL http://www.example.com/demos/jqgrid. Why it has been developed like this, you have to ask the people who did it.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63