0

I've added a location block to serve a Laravel app from a sub URI (only) at /todos/

location /todos {
    try_files $uri $uri/ /todos/$query_string;
    index  index.php index.html index.htm;
    root /index.php;
    location ~ \.php$ {
        fastcgi_index index.php;
        fastcgi_read_timeout 300;
        fastcgi_pass   unix:/opt/bitnami/php/var/run/www.sock;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME /opt/bitnami/nginx/html/todos/public/index.php;
        fastcgi_param QUERY_STRING $query_string;
        include        fastcgi_params;
    }
}

But going to /todos/ URI doesn't work (serves up 403 Forbidden), it requires me to actually put in "index.php" - so Laravel only works with /todos/index.php.

What am I doing wrong?

UPDATE: Working config:

location /todos {
    try_files $uri $uri/ /todos/index.php?$query_string;
    index  index.php index.html index.htm;
    root /opt/bitnami/nginx/html/todos/public/;
    location ~ \.php$ {
        fastcgi_index index.php;
        fastcgi_read_timeout 300;
        fastcgi_pass   unix:/opt/bitnami/php/var/run/www.sock;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME /opt/bitnami/nginx/html/todos/public/index.php;
        fastcgi_param QUERY_STRING $query_string;
        include        fastcgi_params;
    }
}

1 Answer 1

1

Your root needs to be:

root $directory_of_your_index.php_file;

And in Location add:

try_files $uri $uri/ /index.php?$query_string;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Updated the question with working config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.