Skip to content

Commit

Permalink
Fix parsing TRUSTED_PROXY_IP (mastodon#18051)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykzts committed Apr 19, 2022
1 parent 50a088f commit 5781d1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

# Allow to specify public IP of reverse proxy if it's needed
config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split.map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present?
config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split(/(?:\s*,\s*|\s+)/).map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present?

config.force_ssl = true
config.ssl_options = {
Expand Down
2 changes: 1 addition & 1 deletion streaming/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const startWorker = async (workerId) => {

const app = express();

app.set('trusted proxy', process.env.TRUSTED_PROXY_IP || 'loopback,uniquelocal');
app.set('trust proxy', process.env.TRUSTED_PROXY_IP ? process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) : 'loopback,uniquelocal');

const pgPool = new pg.Pool(Object.assign(pgConfigs[env], dbUrlToConfig(process.env.DATABASE_URL)));
const server = http.createServer(app);
Expand Down

0 comments on commit 5781d1d

Please sign in to comment.