Hi
I’m running Nginx with php7.2 (https://moss-pultz.com). My config is:
location /
{
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
My panel’s config.php is:
return [
'panel' =>[
'install' => true
]
];
I’m getting the error: “The panel cannot connect to the API”.
Hope someone can help.
Sean
Is there anything in the server logs? Oh, your config is shown as plain text on the page? There seems to be something wrong in your config file?
The opening <?php
tag missing?
I use Laravel Forge and its default Nginx config works out-of-the-box with Kirby 3. I only had to add some rewrite rules to hide folders.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yoursite.com;
root /home/forge/yoursite.com;
# SSL stuff goes here
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# Cachebuster
# location ~ (.+)\.(?:\d+)\.(js|css)$ {
# try_files $uri $1.$2;
# }
# Media: images, icons, video, audio, HTC
location ~ \.(jpe?g|gif|png|webp|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# Don't hint these as folders
rewrite ^/(content|kirby|site|vendor)\/?$ /error last;
# Block content
rewrite ^/content/(.*).(txt|md|mdown|markdown)$ /error last;
# Block all files inside these folders from being accessed directly
rewrite ^/(kirby|site|vendor)/(.*)$ /error last;
# Block root /home/forge/yoursite.com;
rewrite ^/(\.env|\.env\.example|composer\.json|composer\.lock|package.json|yarn.lock|mix-manifest\.json|webpack.mix.json|tailwind.js|readme\.md)$ /error last;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/yoursite.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
I hope that helps you figure out what’s going on on your side.
Ha… yeah, it was that simple. I just assumed these were included in a larger file that had the start/end php tags.
It’s working now. Thanks for the help!