1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 16:12:49 -05:00

Platform/pm 2138/add nginx to known proxies (#3012)

* Add nginx to known proxies

* Only add nginx proxy if standard self host deployment

* Style changes

* Add forwarded headers config to events server

* Add known proxy forwarding to missing services

* Catch DNS errors in adding nginx proxy

* Update src/SharedWeb/Utilities/ServiceCollectionExtensions.cs

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>

---------

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
Matt Gibson
2023-06-14 09:33:26 -05:00
committed by GitHub
parent 73c721ede3
commit bdd5e0916e
5 changed files with 34 additions and 3 deletions

View File

@ -540,10 +540,17 @@ public static class ServiceCollectionExtensions
if (!globalSettings.UnifiedDeployment)
{
// Trust the X-Forwarded-Host header of the nginx docker container
var nginxIp = Dns.GetHostEntry("nginx").AddressList.FirstOrDefault();
if (nginxIp != null)
try
{
options.KnownProxies.Add(nginxIp);
var nginxIp = Dns.GetHostEntry("nginx")?.AddressList.FirstOrDefault();
if (nginxIp != null)
{
options.KnownProxies.Add(nginxIp);
}
}
catch
{
// Ignore DNS errors
}
}