Skip to content

Commit

Permalink
Merge pull request #584 from TeddiO/master
Browse files Browse the repository at this point in the history
Adds an override flag to change behaviour when Jets is behind an ELB running Jets Server
  • Loading branch information
tongueroo committed Sep 1, 2021
2 parents 041de85 + 3781165 commit c47d2cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/_docs/extras/elb-server-override.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: ELB Server Override Flag for jets server
---

## Background

While the goal of Jets is to create and deploy serverless services, there is often a need to run Jets in the server mode to debug your applications.
This may include hosting it on AWS and having it reachable through a load balancer such as an Application Load Balancer.


In the event you have a need to run it through an Elastic Load Balancer while running `jets server`, setting `JETS_SERVER_ELB_OVERRIDE` to `1` will guarantee `jets server` behaviour even when behind an ELB.
1 change: 1 addition & 0 deletions lib/jets/controller/middleware/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def mimic_aws_lambda!(env, vars)

def on_aws?(env)
return false if Jets.env.test? # usually with test we're passing in full API Gateway fixtures with the HTTP_X_AMZN_TRACE_ID
return false if ENV['JETS_SERVER_ELB_OVERRIDE'] # If we're using an ELB and Jets is inside a container running jets server, we don't want to pretend we're on AWS.
on_cloud9 = !!(env['HTTP_HOST'] =~ /cloud9\..*\.amazonaws\.com/)
!!env['HTTP_X_AMZN_TRACE_ID'] && !on_cloud9
end
Expand Down

0 comments on commit c47d2cf

Please sign in to comment.