Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

361
Views
How to configure Express' trust proxy when deploy to Elastic Beanstalk and Cloudflare DNS?

I have a node.js app that is deployed to Elastic Beanstalk (EB), which uses nginx as a reverse proxy. Nothing fancy there, just used EB with a Docker config. I then added my EB's location, e.g. **.elasticbeanstalk.com as a CNAME in Cloudflare, and enabled SSL.

In my app I set:

app.set("trust proxy", 2) // What is the right value here?
sessionCookie = {
  httpOnly: true,
  secure: true, 
  maxAge: 24 * 60 * 60 * 1000
}

I've experimented with all of the below and all of which do not work:

app.set("trust proxy", 1) // or 2,3,4
app.set("trust proxy", ["loopback", "linklocal", "uniquelocal"])
app.set("trust proxy", function(ip) { return true })
app.set("trust proxy", true)

Any suggestions? If secure is set to false, then it works, but I don't think it's wise to set secure to false?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!