Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Installation & Hosting

404 error with Grav on Lightsail Nginx Instance

Started by Nazim 7 years ago · 3 replies · 841 views
7 years ago

Dear Experts,

I am trying to get a simple grav site working on a lightsail instance with Nginx but have been stuck at 404 error when navigating to the typography page which comes as part of the default installation of Grav.

When I access the site using the ip address, the navigation is working fine and I can access the site at https ://ip/myapp and https ://ip/myapp/typography is also working fine.
But when I access the site with the domain name (https ://www.myapp.com), the main page opens fine. But, when I navigate to https ://www.myapp.com/typography, I get an 404 error.
NGINX Error logs shows the following:
2019/03/29 12:39:53 [error] 3219#0: *55 open()

"/opt/bitnami/apps/myapp/htdocs/typography" failed (2: No such file or directory), client: xxx.xx.xxx.xxx, server: myapp.com, request: "GET /typography HTTP/1.1", host: "www.myapp(dot)com", referrer: "https: //www.myapp(dot)com/"

My configuration follows the bitnami documentation for nginx and the site is located in a subfolder under /opt/bitnami/apps/myapp/htdocs/

My configuration is as below:
The configuration files follow the same structure as per bitnami documentation.

vhosts file:

server {
listen 80;
root "/opt/bitnami/apps/myapp/htdocs";
server_name myapp(dot)com www.myapp(dot)com;
include "/opt/bitnami/apps/myapp/conf/nginx-app.conf";
}

server {
listen 443 ssl;
root "/opt/bitnami/apps/myapp/htdocs";
server_name myapp(dot)com www.myapp(dot)com;
ssl_certificate "/opt/bitnami/apps/myapp/conf/certs/server.crt";
ssl_certificate_key "/opt/bitnami/apps/myapp/conf/certs/server.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
include "/opt/bitnami/apps/myapp/conf/nginx-app.conf";
}

nginx-prefix.conf file:

location /myapp {
alias "/opt/bitnami/apps/myapp/htdocs/";
include "/opt/bitnami/apps/myapp/conf/nginx-app.conf";
}

nginx-app.conf file:

Begin - Index

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

End - Index

Begin - PHP

location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_read_timeout 300;
fastcgi_pass unix:/opt/bitnami/php/var/run/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}

End - PHP

I am not sure which part of the configuration is causing ther error and your help would be much appreciated.
Thank you.

7 years ago

See if custom_base_url: '/myapp' in your Grav system.yaml file works?

7 years ago

Hello, I tried this but the custom base URL is now adding path to the folder which is already set in the nginx config.
Adding '/myapp' breaks the whole site.

Suggested topics

Topic Participants Replies Views Activity
Installation & Hosting · by antoinep, 13 hours ago
5 60 7 hours ago
Installation & Hosting · by Jürgen Dietrich, 7 months ago
0 62 7 months ago
Installation & Hosting · by rappluk, 8 months ago
0 62 8 months ago
Installation & Hosting · by N, 12 months ago
3 72 12 months ago
Installation & Hosting · by Youle, 1 year ago
1 61 1 year ago