when install cachet in subfolder example "http://localhost/cachet/" css and js error 404
what is the solution ?
We don't support subfolder installs because laravel doesn't properly support them.
You can get it to mostly work if you set the application url correctly in the .env file.
@GrahamCampbell do you have any suggestions on how to set it correctly? I am running into the same issue and have tried different variations of APP_URL that point to the external hosted url, internal localhost url including the subdirectory, etc and haven't had any luck.
I would need this too. How is "correct" in this case?
@gerhard-tinned it really isn't supported, sorry.
Solution:
Put it on a subdomain/domain, then either:
a. 301/302 HTTP redirect from a subfolder to subdomain
or b. iframe to subdomain
This is not a solution, this is in best case a workaround for a badly designed web-application.
A web-application that is not able to run from a subdirectory is actually a sign for bad web development practice from my point of view.
A web-application that is not able to run from a subdirectory is actually a sign for bad web development practice from my point of view.
Please could you explain your point of view?
Hey guys, actually laravel supports being in a subfolder pretty well.
My nginx configuration includes this part:
location /cachet {
alias /var/www/Cachet/public;
try_files $uri $uri/ @cachet;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
location @cachet {
rewrite /cachet/(.*)$ /cachet/index.php?/$1 last;
}
... and you're able to provide every laravel application in a subfolder (in this case /cachet).
From this point on, it's just a matter of "is the application programmed the way it supports being in a subfolder?".
Right now Cachet seems only to support this partly - I'll make some changes to provide a better support for both (normal and subfolder) and will start a pull request.
We use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please use our support channels to get help with the project. You can signup to our Slack channel at https://cachethq-slack.herokuapp.com/
Kindly help me out with this. I am trying to get cachet installed in subpath via nginx. But, I am stuck. I installed cachet through Docker. Hence, working with alias like @bjoernffm suggested may not work well. Looking for something which can redirect requests to my port like how normal applications work.
I've been working this out on the slack support for the last few days.
Using a configuration like this with nginx:
location ^~ /status {
alias /var/www/html/cachet/public/;
try_files $uri $uri/ @cachet;
location ~ \.php {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
include fastcgi_params;
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
}
}
location @cachet {
rewrite /status/(.*)$ /status/index.php?/$1 last;
}
this will correctly serve the entire laravel application from a subdirectory (in this instance example.com/status) and resources load properly (images, css, setup pages like example.com/status/setup) but the solution is not complete due to POST requests to setup the database (or, any other request in the application, this is just the first point to get a blocking 404) will request at https://example.com/setup/step1 and get a 404 when we will need it to request at https://example.com/status/setup/step1.
Environment variables such as APP_URL do not appear to adjust any subdirectory in the resources requested. Is there a different configuration to change? Is there some adjustments that can be made?
I'm posting this update here to help those who reference this issue with similar problems. I'll try to include any full solutions if they become available.
Note: Perhaps not the right place to put this addendum, but there seems to be a lingering question as to the design decision of serving from a subdirectory. There are many reasons such as a requirement to use an organization's single-sign-on service, simplifying SSL termination (no wildcards or multiple certificates) at a front-facing load balancer, general SEO, and integration from other 3rd party marketing tools. Although they come with pros/cons, deciding to serve from a subdirectory seems like a reasonable decision specific to a use-case.
@jaredvacanti thanks for sharing your configuration ! Maybe this could be integrated in the documentation ?
Most helpful comment
Hey guys, actually laravel supports being in a subfolder pretty well.
My nginx configuration includes this part:
... and you're able to provide every laravel application in a subfolder (in this case /cachet).
From this point on, it's just a matter of "is the application programmed the way it supports being in a subfolder?".
Right now Cachet seems only to support this partly - I'll make some changes to provide a better support for both (normal and subfolder) and will start a pull request.