How to connect to docker container with nginx
Hello friends,
Starting with the package:
https://railway.app/template/o3MbZe
This is Nginx static site docker container. I have my own nging configuration I want to run but I really don't know how can I do this. Any help will be be welcomed π
Details:
I have my backend running on railway and my site on vercel.
My plan is to connect somehow my domain to the nginx service. Then from the nginx service proxy the network on port 80 and 443 to the vercel domain. And for port lets say 8000 to my backend on railway.
Maybe my approach is fundamentally wrong and you can share how this should be done.
Thank you!
74 Replies
Project ID:
e49f5ed7-ba90-4ebe-b635-e8604a8b2ebc
e49f5ed7-ba90-4ebe-b635-e8604a8b2ebc
what will this nginx config serve?
More like a reverse proxy if I'm understanding properly
Something like this
what are you proxying to? just asking so I can understand better
I have railway with my Database + Redis + API and I want to host it on my domain on port 8000 lets say. And my website what is on vercel for now (in the future will be on railway to for consistency) should be on port 80 and 443 on my domain
So if I type domain.com ill go to my vercel, but if i open postamn and type domain.com:8000/api I'll ask my api
you want to reverse proxy from the railway service to your site on vercel?
If this is possible, if not I can transport my page to railway
But that was the plan first. Is this understandable? I'm not sure if I explained it properly
no no I get what you wanna do, and I'll help you do it if you really want, but I just don't think that's the best idea
what's the problem with having the frontend on vercel and the backend on Railway? vercel is made for frontend hosting, railway is geared more towards backend hosting
vercel for frontend and railway for backend is a super common approach
I think it makes sense. But my problem is how can I connect it. That I have only one domain and different redirects on different ports
ChatGPT helped me with creating the config file but I don't know how to put it into the container
in vercel you have the domain set to domain.com and on Railway you have the domain set to api.domain.com, then you call api.domain.com from the frontend
I don't have subdomains like
api.domain.com
I only have domain.com
I can explain why I need backend to work from domain.com. This is because my mailchimp configuration requires that my emails are sent to the clients with the correct email domain.
[email protected] => mailchimp requires it to be sent really from this domain. That is why I'm trying to do this with the portsYou'd have to run domain.com on the same host and then use a reverse proxy or similar to manage the routing of the traffic between Railway/Vercel
That is exacly what I want to do π
The problem is I don't know how Could you help me? π
The problem is I don't know how Could you help me? π
You should be able to call Mailchimp from server though?
It shouldn't matter what domain you're on
It matters for mailchimp
If i send an email from [email protected] and the @domain.com isn't the domain I've sent from then the email is being blocked
But there's not really any way for Mailchimp to know your API isn't at example.com
Your API could be on api.example.com and Mailchimp wouldn't be any wiser unless there was RDNS on your IP
I don't know what RDNS is. I only know that I tried it and all my emails were blocked π¦
sam, there's no need to over complicate things
if you have domain.com then there's nothing stopping you from creating an api.domain.com to use on railway
^
mail servers don't come into play here either
Konrad, do you have your frontend working on vercel?
Yes
You do not need todo anything with hosting to send an email with them.
Set the dns records mail chimp need and youβll be good to go with sending emails.
Luna no over complicating things π
Unless they're using Mandrill
They use mandrill
we are no where near the need to talk about mail anything yet, everyone slow down
Luna I've really tried It, with no luck
one small step at a time
Itβs still just set DNS and be done with itβ¦ idk why this is being over complicated
yeah i think their problem is with getting the transactional email from their backend to mandrill
one topic at a time, we don't yet need to talk about mail servers yet
Konrad, is your frontend accessable from a domain.com on vercel?
Yes it is
for both http + https
okay and your backend, do you have it running on Railway?
Yes but with the normal Railway domain
this random I mean
my-domain.up.railway.app
gotcha, but does it work from the railway domain?
(I lost signal)
Excuse me, what do you exacly mean by that?
If i type the
my-domain.up.railway.app/api
my backend (swagger) is run.that's exactly what I mean, your backend, from the railway domain works as expected?
Yes
does your frontend on vercel make the api calls to the backend on railway just fine?
I'm not asking my backend from my frontend. I have a mobile app. Frontend is just for users to read about the app.
The mobile app calls the backend with the railway domain with no problem. Backend is working properly.
okay cool, I don't have any information about what your app is so forgive me for using such broad terms
so would you say everything works, at least from a purely functional standpoint?
I appreaciate any help, thank you for spending your time helping me
Yes everything works fine
we have been saying domain.com, but would you mind telling me your actual domain?
not its just a template but yes https://www.auri.chat
We prepare for release in upcoming months
and who did you buy the domain with?
Now we just use dummy template from astro
NameCheap
did you know railway supports custom domains? you could have api.auri.chat connected to your railway service, and railway will handle SSL for you
I know that you can connect a domain to a service in railway. I did it for testing few times. I never tried with subdomains tho
subdomains are even easier
what do you currently have in the domains section of the railway service
isn't that a problem with SSL cerificates? I think the wildcards one are expensive (or I'm wrong)
for api.auri.chat there is not wildcards involved, but even if there was SSL certs on wildcard domains are still completely free
you have access to namecheap right?
yes yes
I've added the subdomain
and it gave you a cname, keep that cname in a notepad
now just open up namecheap's advanced dns configuration menu and add a new cname type subdomain with that cname value railway gave you
done
and can you show me what you've done for that subdomain in namecheap?
CNAME with api prefix and the link
okay looks like that new subdomain is all working, can you confirm that for me?
It works but is not secure no https :/
works on https for me just fine, maybe clear your SSL cache?
On incognito it works
So probably cache, youre right
so you'd just have to update the domain that your app calls to your new api subdomain right?
No the mobile app could use the random railway domain. I needed it for the api to send emails. With the subdomain the maindrill doesn't want to send emails
but there is hope
let me check one thing
This will not work
Mandrill requires from my now my @api.auri.chat email that I don't have to verivy the domain. This step is required
I have to find another way to make this work
Thank you for help Brody
I have to go to sleep
I think you'd want to make a new domain, like mail.auri.chat and use that for all mail related setup
but the whole google businnes is connected to auri.chat
yes I'll find a way
thank you
take care!
right but you'd definitely want to have mail.auri.chat for everything mail related
you take care too!!