10 months ago
Hi Railway Support Team,
I hope this message finds you well. I am currently working on a project hosted on Railway and am interested in integrating AWS CloudFront to enhance the delivery speed of my content. However, I am unsure about the best way to configure this setup in the Railway environment.
Could you please provide me with guidance or direct me to any documentation that covers the integration of CloudFront with a Railway-hosted project? Specifically, I am looking for steps to set up and configure CloudFront to work seamlessly with my existing deployment.
Thank you for your assistance.
Best regards,
Fahim Mahmud Chisti
15 Replies
10 months ago
Hey! Do you already have a strategy mapped out, or where are you with designing your solution?
10 months ago
I just trying to setup CloudFront on railway with fastify server custom domain is working but CloudFront domain how I will add but I do not found a good solution yet
10 months ago
Gotcha. Are you trying to follow a guide that you can point me to so I understand better? If not, I will make time to explore this in the next couple of days. Someone in the community may also help out before then, but I'll make sure to get you an answer!
10 months ago
Where I will get the docs? Can you please explain/create a docs it will be very helpful for me. Thank you
10 months ago
Yep that's what I'm thinking, it'd be great to have some documentation in our site. Currently, we do not have that, but I was curious if you were following a guide from AWS or otherwise. No problem if not. I have a ticket for myself to explore it. Will keep you updated.
10 months ago
Thank you so much
10 months ago
Hey! I wanted to check in and let you know I've been working on this and have an outline for a guide which I am going to try to publish tomorrow. But, wanted to share some quick notes on the implementation in case it's helpful -
The request path will be:
Custom Domain -> CloudFront -> Railway
... So you will not configure your custom domain in Railway, but in AWS.
For SSL - When you set up your CloudFront distribution, you should go through the flow to Request an SSL certificate. From here, AWS Certificate Manager will provide you with a CNAME which you should configure on your domain in your provider (DNSimple, Namecheap, etc)
To route your CloudFront distribution to the service in Railway, you will add the Railway-provided domain as an Origin with HTTPS only configured
To route your custom domain to the CloudFront distribution, you will have to add a CNAME or ALIAS record (depending on your domain provider) with value
@
orwww
(or both) and set the value to the CloudFront distribution's provided domain
You will also need to add your custom domain as an Alternate domain name in your CloudFront distribution settings
Again, these are very quick/rough notes on the things that were a bit vague for me. I will do my best to push the guide into docs tomorrow and will let you know when it's out.
10 months ago
A day late, but I've published this! https://docs.railway.app/tutorials/add-a-cdn-using-cloudfront
If you have any questions/problems, please let me know
10 months ago
You are so awesome! Thank you so much
10 months ago
I setup all things buthttps://d2tnkzueihbqrc.cloudfront.net/But its showing me Nothing here... yet
10 months ago
Please have another look at the guide Melissa wrote, you forgot to overwrite the HttpOrigin.
10 months ago
Same I didhttps://d2tnkzueihbqrc.cloudfront.net/https://backend-development-a56a.up.railway.app/
10 months ago
Please show me the following equivalent line of your code -
// Replace with the Domain provided by Railway
const origin = new origins.HttpOrigin('RAILWAY PROVIDED DOMAIN');
6 months ago
FYI
I encountered the same issue. The guide might use "Legacy cache settings" via CDK. When creating a distribution from the UI, the Origin Request Policy recommends "AllViewer". This option is set to send all viewer headers, but sending these headers causes the same problem. I don't understand why, but I was able to resolve the issue by adjusting it to not send these headers.
Attachments
6 months ago
Thanks for the details @isoppp.
the stack definition doesn't set an origin request policy in the guide, but maybe it needs to be updated to do so, that way we can explicitly set it to not send the headers.
it's been a while since I worked on this, so I'll have to carve out some time to refresh my memory and then test, but this is very helpful!