agentejo / cockpit

Add content management functionality to any site - plug & play / headless / api-first CMS
http://getcockpit.com
MIT License
5.39k stars 522 forks source link

Redirected to auth/login with 404 after install #686

Closed timharek closed 6 years ago

timharek commented 6 years ago

After the installation was successful, I got redirected to "url/auth/login" with a 404 Not Found page.

Ubuntu 16.04 PHP 7.2.2-3 Apache2 2.4.18 mod_rewrite is enabled

linksmith commented 6 years ago

Same problem, but with nginx

joerou commented 6 years ago

I just got this working, I noticed that the htaccess file didn't copy over in the main directory so I copied that one to the server and everything seems to be working

timharek commented 6 years ago

@joerou I tried adding the .htaccess, but it didn't do anything...

Jolva commented 6 years ago

Not sure if this will help anyone else, but I was able to correct this issue by following the below guide to test mod_rewrite and htaccess (turns out I missed a configuration step in Apache for mod_rewrite). This is written for the Bolt CMS, but applies to any Apache setup:

https://docs.bolt.cm/3.4/howto/making-sure-htaccess-works

timharek commented 6 years ago

@Jolva Thanks a lot for the link, I actually thought I had enabled .htaccess via the apache2.conf - but I was mistaken! Thanks a lot :D

gswilcox01 commented 5 years ago

I just got this issue as well. I had to update the default httpd.conf with "AllowOverride All". Shouldn't the requirements or install docs be updated with this info?

boticello commented 5 years ago

Can anyone explain what the solution to this problem is with nginx? I've just installed Cockpit on a Vagrant box with nginx and had this same problem.

fais3000 commented 5 years ago

Can anyone explain what the solution to this problem is with nginx? I've just installed Cockpit on a Vagrant box with nginx and had this same problem.

@boticello Did you find the solution for Nginx?

boticello commented 5 years ago

@fais3000 No. In the end I switched to a cloud solution (Prismic). It was easier to get started. I’ll try Cockpit again another time.

Jolva commented 5 years ago

@boticello Did you try the steps outlined here? I was pulling my hair out with the same 404 issue.

boticello commented 5 years ago

@Jolva I haven't yet tried the solution you posted. Thanks for pointing me to it. When I try Cockpit again I will use it and post my results to this thread.

fais3000 commented 5 years ago

@boticello I ended up solving it by following https://github.com/agentejo/cockpit/issues/704

I am hosting cockpit in a subdirectory. I was blaming Nginx and htaccess for the 404 errors. Found out that cockpit automatically redirects to the root of the domain after auth instead of relative to the project root. I added a defines.php to overwrite those paths. Which solved it for me.

gabskoro commented 5 years ago

For all the ones who have problems running it under nginx. This problem was already discussed in #19 and there you can find the fix. Also there is a link to the nginx server config which worked for me (hence the try_files $uri $uri/ /cockpit/index.php?$args;)

smplman commented 5 years ago

I'm having a similar issue, but mine is with the api routes and not the CMS routes. When I try to hit /api/collections/get/ i get this error:

php-fpm_1          | 172.19.0.4 -  20/Feb/2019:14:52:52 -0500 "GET /index.php" 404
nginx_1            | 2019/02/20 14:52:52 [error] 6#6: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 170.20.11.2, server: mysite.com, request: "GET /api/collections/get/projects?token={token} HTTP/1.1", upstream: "fastcgi://172.19.0.3:9000", host: "cms.mysite.com"

So it appears that using routes nginx does not go back to the default index.php but tries to load one from {root}/api/collections/get/

Here is my nginx config:

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

    location ~* \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_pass    php-fpm:9000;
        include         fastcgi_params;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME         $fastcgi_script_name;
        fastcgi_param   PATH_INFO           $fastcgi_path_info;

        fastcgi_param COCKPIT_URL_REWRITE On;
    }

EDIT: I fix the issue $document_root$fastcgi_script_name; shoud have been $document_root/$fastcgi_script_name;

bastianhilton commented 4 years ago

So for me it was pretty simple. I was installing cockpit on a2hosting with cpanel shared hosting. When i uploaded the cockpit zip file and extracted it. I moved all the files and folders to my subdomain's root directory and ran the install. When i attempted to access the login page, it showed 404. What i didn't realized was that when i moved all the files and folders over it didn't move over hidden files, once i chose the option to show hidden files and folders and moved those over to the root directory of my install. I was then able to access my cockpit login page. Hope this helps someone else with a similar issue.

eko2one commented 1 year ago

I just got this issue as well. I had to update the default httpd.conf with "AllowOverride All". Shouldn't the requirements or install docs be updated with this info?

Definitive requirement in Apache Configuration (do not forget to add this to both virtual hosts ports 80/443)

<Directory /var/www/<cockpit_directory>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
PaleoCruiser commented 1 year ago

Genius! Now it worls for me on Win10, PHP8 (threaded php-8.2.6-Win32-vs16-x64) and Apache 2.4