0

I have Cockpit CMS installed and with this conf file, every real folders where I have files or subwebsites that I want to share or access are interpreted as 404 pages, I guess because of this part :

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

Then I need to specify every link and folders to enable access. This is kinda constraining. Do you have an idea to avoid this?

server {
    listen 443 ssl;
    ...
    server_name site.com;
    root /var/sites/_site.com/www;

    index index.php index.html;


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

    location /cockpit {
        try_files $uri $uri/ /cockpit/index.php;
    }

    # Enable PHP with path_info
    location ~ ^(.+\.php)($|/) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        include fastcgi_params;
    }

    # Files index
    location /files { autoindex on; }
    location /specific-link {}
    location /specific-folder {}
}

1 Answer 1

1

Maybe this syntax variation will help you?

 try_files $uri $uri/ /index.php$uri?$args;

This tries folders as well as files before passing it on to the backend if they don't physically exist.

3
  • this actually works for any folder/link, but now my homepage returns a 404…! any thought?
    – flks
    Commented Feb 3, 2016 at 0:30
  • Try adding an if or additional location block to special-case the homepage. Commented Feb 3, 2016 at 1:01
  • thank you! works like a charm with this additionnal rule: location = / { try_files $uri /index.php$uri?$args; }
    – flks
    Commented Feb 3, 2016 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .