1
votes

I am building a docker collection that will eventually have the following containers (and more)

web (nginx)

proxy (reverse proxy nginx)

php-fpm

the web will have the allowance for several frameworks to be added via folders and subfolders

./folder1/folder2/codeigniter ./folder3/folder4/laravel

the folders for codeigniter and laravel are symlinks to a public folder

the index.php page works and shows the default routes without issue.

but when I try to get to a different page such as /folder3/folder4/laravel/index.php/path/somwhere

I get a 404 error message.

I want to be able to do this without mapping an nginx location directive for EVERY FOLDER...

this is what my conf files looks like:

server {

    listen 8100 default_server;
    listen [::]:8100 default_server ipv6only=on;

    server_name localhost;
    root /var/www/public;
    index index.php index.html index.htm;

    location / {

        add_header 'Access-Control-Allow-Origin' '*';
        add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
        add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";

        if ($request_method = 'OPTIONS') {
          add_header 'Access-Control-Allow-Origin' '*';
           #
           # Tell client that this pre-flight info is valid for 20 days
           #
           add_header 'Access-Control-Max-Age' 1728000;
           return 204;
        }

        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        try_files $uri $uri/ index.php?$args;


        fastcgi_pass php-fpm-56:9000;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

}

what am I doing wrong here?

keep in mind, I want to use "/folder/index.php/path/path"

I DO NOT WANT "/folder/path/path"

nor do I want to create a location entry for every new folder I create

1
Currently you are using a PHP configuration that requires the URI to end with .php (see the regular expression in your location statement ends with a $). You need to use a PHP configuration that works with path info. See this Nginx example. - Richard Smith

1 Answers

0
votes

i try to use codeifniter,

as an example

I will access

http://192.168.100.100/CI/CI_1/CI_1/index.php/main/index

enter image description here

after I tried this way, the results are according to what I attach

location  /CI/CI_1/CI_1 {
  autoindex on;
  try_files $uri $uri/ /CI/CI_1/CI_1/index.php?/$request_uri;
}

Thanks