Deployment Issue: Nginx Container Not Responding (503 Error)
After successfully deploying my Laravel application with Dockerfile to Railway, I am encountering a 503 error when trying to access the application using the provided URL below.
Deployment Details:
Project Id: 5eff00b6-887c-4fb9-9f2f-02c7fb94d78c
Deployment URL: https://innoscripta-assessment-backend-production.up.railway.app/
Steps Taken So Far:
1 - Checked Nginx Configuration: I reviewed the Nginx configuration file and ensured that it is properly set up to route traffic to the Laravel PHP-FPM container.
2 - Verified Environment Variables: I have confirmed that all the required environment variables, such as DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD, and others, are correctly set in the railway environment.
3 - Restarted the Containers: I tried restarting all the containers, but the issue persists.
4 - Verified Port Mapping: I have confirmed that the Nginx container is correctly mapped to port 80 on the host machine, and the Laravel PHP-FPM container is mapped to port 9000.
5 - Reviewed Application Logs: The logs for the app-1 container do not show any errors. It only displays the following message: "[03-Aug-2023 23:47:00] NOTICE: fpm is running, pid 1 [03-Aug-2023 23:47:00] NOTICE: ready to handle connections." and I do not see any error logs related to Nginx in the railway dashboard logs (I only see the app container logs).
Request for Assistance:
I kindly request your support in identifying and resolving the root cause of the issue. Please investigate the Nginx container's logs and any other relevant logs that may help pinpoint the problem. Any insights or guidance to resolve this matter would be greatly appreciated.
Please let me know if you require any further information to assist in resolving this issue.
61 Replies
Project ID:
5eff00b6-887c-4fb9-9f2f-02c7fb94d78c
have nginx listen on a non privileged port like 8080, and then in your railway service variables set a PORT variable to 8080 as well
Changed the nginx.conf file and added a PORT variable set to 8080 as well and redeployed. No luck 😦 here is my file:
show me your service variables please
also, have you tried deploying your app with nixpacks instead of a dockerfile?
No, I don't know much about deploying with nixpacks. Do you need the values of the env vars or you want to check the keys only?
I just wanted a screenshot, now you've shown me all your keys, please go and regen them
np i changed the values keeping the general structure
send your dockerfile please
does php:8.1-fpm include nginx?
i don't think so
Try adding nginx to the apt-get install command then?
I think you should try deploying with nixpacks
^ this
I have spent rather an amount of time getting the Nixpacks PHP provider to Just Work™️, so hopefully it should.
spoiler alert, it's still sub par
what this involves is removing your dockerfile and nginx.conf
You can also just rename them to
.bak
or something if you want, to keep them around^ this
Oh man, i really don't know anything about nixpacks and I don't have time for it (this project was for an assessment and I'm at the end of the deadline)
You can just delete those two files and it should Just Work™️
That's the point of nixpacks
took the words right out of my fingers
Oh yeah so no configuration files like Dockerfile whatsoever?
that's the point
zigacktly
aight lemme try it
nixpacks probably won't pick up on the libpg libjpeg etc stuff though
it might
I'm not sure
depends on how well you did with the php provider
It'll install the required extensions, which should hopefully have such things as dependencies
hopefully ™️
™️©️
®️
😬
returned 403 😄
nooooooo
hey that's better than 503!!
oh wait
what does the page say
Understand here, none of us are PHP developers
me neither brotha first time trying it
I have this in the deploy logs tho: "Looks like your app is listening on 127.0.0.1. You may need to listen on 0.0.0.0 instead."
I wrote the provider, but I'd still rate myself as a beginner
hrrrm
could you send the logs?
well that's weird
I don't know where that message popup is coming from, you can ignore it
oh I see where it's coming from. you can still ignore it though
hmm
do you have a
public
directory?oh shii, do i need to remove the .dockerignore too?
no, it's using nixpacks
do you have a
public
directory in your app though?I ve a public directory in the root
all this is nixpacks doing black magic with Perl regexes to tell you that your app might have problems
oh, I think I might know what's happening
What are the permissions on the
public
directory?
wait nvm
I'm tired, disregard that questionI have .htaccess file inside the public directory if you mean that
.htaccess won't actually do anything here, since this is Nginx
Try adding a
nixpacks.toml
to your project:
see this is what I mean by subpar, you shouldn't need to be chmod'ing anything
s/subpar/secure
Nginx runs as a different user so people can't hack your server
doesn't the chmod in your nixpacks.toml undo anything that was secure
shhh
nope, didnt work
couldnt even open it?
oh oops
I'd renamed the dockerfiles to .bak but i think it was still picking up those for some reason removing those entirely worked tho
huh
that is very odd
anyway, glad it works!
classic home page returns i'll test the api routes now
but thank you guys for the assistance!
It was definitely using nixpacks though, so I'm confused
no problem!
🥳