Can't get any route using php and slim framework

It's a small app that I wanted to deploy. Everything works normal but when I try to get into a route I get a 404 error. I think the .htaccess file is not working like it does locally. Works: https://slim-php-deployment-production-8419.up.railway.app/ Not: https://slim-php-deployment-production-8419.up.railway.app/test a6ace02e-d783-426b-9daf-613e795ce691
27 Replies
Percy
Percy2y ago
Project ID: a6ace02e-d783-426b-9daf-613e795ce691
frich14
frich14OP2y ago
GitHub
GitHub - AgustinFrich/slim-php-deployment: Aplicación Slim Framewor...
Aplicación Slim Framework 4 PHP con despliegue automático 🚀 - GitHub - AgustinFrich/slim-php-deployment: Aplicación Slim Framework 4 PHP con despliegue automático 🚀
Brody
Brody2y ago
an htaccess file is not applicable for the php provider on railway since it uses nginx, but you can provide your own nginx.conf, this explains a little on how you can do that https://nixpacks.com/docs/providers/php
frich14
frich14OP2y ago
When I add a nginx.conf, even if it doesn't have any configurations, I get an "Application failed to respond" but doesn't crash or gives any log.
Brody
Brody2y ago
can you send your nginx config
frich14
frich14OP2y ago
worker_processes 5;
daemon off;

events {
worker_connections 4096; # Default: 1024
}

http {
index index.html index.htm index.php;
default_type application/octet-stream;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts

server {
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

}
}
worker_processes 5;
daemon off;

events {
worker_connections 4096; # Default: 1024
}

http {
index index.html index.htm index.php;
default_type application/octet-stream;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts

server {
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

}
}
I tried with and same output. It gives me an error if I don't put events or if it has any syntax error
events {
worker_connections 1024;
}

http {

server {
index index.php;
}
}
events {
worker_connections 1024;
}

http {

server {
index index.php;
}
}
Brody
Brody2y ago
please reference the nginx config file in the link I sent you
frich14
frich14OP2y ago
GitHub
nixpacks/nginx.template.conf at main · railwayapp/nixpacks
App source + Nix packages + Docker = Image. Contribute to railwayapp/nixpacks development by creating an account on GitHub.
Brody
Brody2y ago
yes you'll need to modify that to redirect all requests to index.php
frich14
frich14OP2y ago
I've tried modifying that but the application fails to respond every time, and only works again if I delete the nginx.conf
Brody
Brody2y ago
try without modifying, /test wont work, but let me know if the root endpoint does at least work
frich14
frich14OP2y ago
Root doesn't work when I have the nginx.conf
Brody
Brody2y ago
none of the routes?
frich14
frich14OP2y ago
None
Brody
Brody2y ago
what status code do you get
frich14
frich14OP2y ago
The app doesn't crash, it is still active
Brody
Brody2y ago
what status code do you get when hitting the root route
frich14
frich14OP2y ago
Sorry, 503
Brody
Brody2y ago
and thats when using the unmodified config?
frich14
frich14OP2y ago
Exactly Or with the empty roules, same thing
Brody
Brody2y ago
okay, i will look into it in a bit
frich14
frich14OP2y ago
Thanks!
Brody
Brody2y ago
frich14
frich14OP2y ago
Thank you so muchhh!!!!!!
Brody
Brody2y ago
all good?
frich14
frich14OP2y ago
All good, yes
Brody
Brody2y ago
awsome
Want results from more Discord servers?
Add your server