3

I have such a project structure

<root>/public/laravel_app/index.php — Laravel index file

<root>/public/index.php — CraftCMS index file

I want to load CraftCMS app at

https://<domain>

and Laravel app at https://<domain>/laravel_app

Here is my vhost.conf

server {
    listen 443 ssl;

    index index.php index.html;

    root /var/www/public;

    ssl_certificate       /var/www/docker/certs/nginx.crt;
    ssl_certificate_key   /var/www/docker/certs/nginx.key;

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

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

I've looked through almost all related SO questions and have tried a lot of stuff, so, if it's possible, please, send suggestions related to my config.

I'm not a sysadmin and I am an Apache user (there it works in such a way without any tweaking), so I apologize, if I'm missing something obvious.

3
  • Is url rewriting for your CraftCMS working perfectly? So that only Laravel url rewriting is broken. Or neither both are works? Commented Oct 30, 2017 at 10:20
  • @DharmaSaputra It's not loading Laravel. I can't get that endpoint. nginx is passing everything through the <root>/public/index.php. Commented Oct 30, 2017 at 10:22
  • @DharmaSaputra or I can make working Laravel by changing the root /var/www/public; to root /var/www/public/laravel_app;, but I can't make working both. Commented Oct 30, 2017 at 10:23

2 Answers 2

3

You should make 2 url rewriting I think, because laravel_app has it's own index.php for rewrite.

server {
    ...

    root /var/www/public;

    ...

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

    location /laravel_app {
        try_files $uri $uri/ /laravel_app/index.php?$args;
    }

    ...
}

Hope this works

Sign up to request clarification or add additional context in comments.

2 Comments

Hallelujah!! Thanks a lot)
If I can help you somehow, feel free to ask)
0

change

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

to

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

Adding the $uri/ tells nginx to look for a directory with the uri name.

1 Comment

Thank you, but it's not working. It's showing to me a CraftCMS error page, so it's loading <root>/public/index.php

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.