Public DB host name is working but private URL is not
Prorject ID: 2a4ccb82-5166-478f-8ad3-5abadca54feb
Solution:Jump to solution
have a look at this docs section https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images
32 Replies
Project ID:
2a4ccb82-5166-478f-8ad3-5abadca54feb
I get this error:
what errors do you get in the deployment logs?
There were no errors in Deployment logs or I am not logging it.
this is your own app?
This is sendy
Sendy - Send Newsletters 100x cheaper via Amazon SES
A self hosted newsletter application that lets you send trackable emails via Amazon Simple Email Service (SES) at 100x cheaper than other hosted solutions.
I made a Dockerfile for this.
send the dockerfile please
and your config.php please
side note, you only need
ARG SENDY_LICENSE_KEY
not any of the other ARG or ENV stuff becuse the rest arent used during buildSolution
have a look at this docs section https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images
I got one question - MYSQLPORT variable is for public URL port right. is there any such for private url port. that is the default 3306
because I would want to control both hostname and port from the variables and is there any variable that is defined by Railway that I can directly use for MYSQLPORT
ideally there would be a pre defined
MYSQLPORT_PRIVATE
variable for you to reference, but unfortunately there isnt, so instead you can do MYSQLPORT=${{MySQL.RAILWAY_TCP_APPLICATION_PORT}}
https://docs.railway.app/reference/variables#railway-provided-variablesI am doing more digging on my own. Will let you know if I make any progress.
did that alpine variable not work?
I am using those variables so that my local Docker builds work
have you set
ENABLE_ALPINE_PRIVATE_NETWORKING=true
as a service variable on railway?Nope. Trying that.
That seems to have fixed the issue.
using that variable.
great!
also do you know any good way to set the server_name parameter in nginx.conf using env variable
I found some complex ways like using some nginx lua scripts and all.
nginx/nginx.conf doesn’t natively support environment variable expansion, Caddy does however, might be worth to switch to Caddy and its frakenphp module
but if setting setting
server_name
to an environment variable is all you want to do, then setting it to localhost
is perfectly finethat will still server the content? nice1
thats what railway does and they still do variable expansion
https://github.com/railwayapp/nixpacks/blob/main/src/providers/php/nginx.template.conf#L27
the nginx is doing a lot of rewrites on the URLs. it would be a pain to switch them to caddy.
thats fair
Once this is done, I will try to publish this template. Would be my first.
that would be a very nice addition, feel free to ping me if you want any template related feedback!
I enabled writing nginx logs to stdout. I think I will also enable php-fpm logs as well.
sounds good to me
also I think it would be cool if railway shell would automatically change the DB url to public url in env variables.
Would make my life easier while running stuff locally.
you could have a dev environment that has the url set to the public one