Add UseForwardedHeaders so /install.sh + backend_ws use https/wss behind Traefik
This commit is contained in:
@@ -23,10 +23,10 @@ for the Plan 1 implementation steps that produced this code.
|
||||
|
||||
```sh
|
||||
dotnet test # all backend tests
|
||||
dotnet run --project backend # starts on http://localhost:5000
|
||||
dotnet run --project backend # starts on http://localhost:5252
|
||||
```
|
||||
|
||||
Hit `http://localhost:5000/health` to verify it's up.
|
||||
Hit `http://localhost:5252/health` to verify it's up.
|
||||
|
||||
## Smoke test against a live deploy
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using backend.Devices;
|
||||
using backend.Install;
|
||||
using backend.Pairing;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -16,6 +17,13 @@ if (Directory.Exists(keysDir))
|
||||
.SetApplicationName("smart-assistant");
|
||||
}
|
||||
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(opt =>
|
||||
{
|
||||
opt.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
opt.KnownNetworks.Clear();
|
||||
opt.KnownProxies.Clear();
|
||||
});
|
||||
|
||||
builder.Services.AddDbContext<AppDbContext>(opt =>
|
||||
opt.UseSqlite(builder.Configuration.GetConnectionString("Default")));
|
||||
|
||||
@@ -42,6 +50,7 @@ using (var scope = app.Services.CreateScope())
|
||||
}
|
||||
}
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user