Hello,
I have an app running via Laravel on my domain, and I want to also host flarum on the same domain but using /forum. I'm using NGINX so I was hoping there might be a way I can achieve this without moving the files out of the public folder etc as described in the docs.
The main problem I have is that when I try and access /forum, it just complains about 404, rather than showing me the Flarum install page. I'm essentially using default Laravel Forge setup, except I have my main Laravel app as 1 site on Forge, and then I created a new "forum" site on forge to use for flarum. I'm certain I'm just missing something because I'm not every experienced with NGINX, but I know this must just be a wrong rewrite or something that I'm missing.
Thanks 🙂
My Nginx config
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/default/before/*;
server {
listen 80;
listen [::]:80;
server_name CENSORED;
server_tokens off;
root /home/forge/default/public;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_dhparam /etc/nginx/dhparams.pem;
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;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/default/server/*;
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/default-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
location /forum {
root /home/forge/forum/public;
index index.php index.html;
try_files $uri $uri/ /index.php?$query_string;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/default/after/*;