Skip to content

Commit

Permalink
More reverse proxy config settings (#5)
Browse files Browse the repository at this point in the history
* Fix fetching submodules ignoring update rule set to none
Bump version to 1.1.1

* Replace libgit2sharp (#3)

* Work on ssh support for repositories

* Add git check to preflight checks
Replace libgit2sharp with just running git commands using process

* Implement reverse proxy header and path base configuration options
Bump version number
  • Loading branch information
juliangiebel authored Sep 21, 2023
1 parent f6638ad commit 5dd42b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
14 changes: 14 additions & 0 deletions SS14.MapServer/Configuration/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ public class ServerConfiguration
/// </summary>
public bool UseHttps { get; set; } = false;

/// <summary>
/// Enables support for reverse proxy headers like "X-Forwarded-Host" if true. Set this to true if run behind a reverse proxy
/// </summary>
public bool UseForwardedHeaders { get; set; } = true;

/// <summary>
/// Sets the request base path used before any routes apply i.e. "/base/api/Maps" with "/base" being the PathBase. <br/>
/// Set this if run behind a reverse proxy on a sub path and the proxy doesn't strip the path the server is hosted on.
/// </summary>
/// <remarks>
/// Add a slash before the path: "/path"
/// </remarks>
public string? PathBase { get; set; }

public int RateLimitCount { get; set; } = 20;
public long RateLimitWindowMinutes { get; set; } = 1;
public bool EnableSentry { get; set; } = false;
Expand Down
19 changes: 17 additions & 2 deletions SS14.MapServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using Quartz;
using Serilog;
using SS14.GithubApiHelper.Extensions;
using SS14.GithubApiHelper.Services;
using SS14.MapServer;
using SS14.MapServer.BuildRunners;
using SS14.MapServer.Configuration;
using SS14.MapServer.Extensions;
Expand All @@ -17,7 +17,6 @@
using SS14.MapServer.Services;
using SS14.MapServer.Services.Github;
using SS14.MapServer.Services.Interfaces;
using Swashbuckle.AspNetCore.SwaggerGen;

var builder = WebApplication.CreateBuilder(args);

Expand Down Expand Up @@ -49,6 +48,12 @@
});
});

//Forwarded headers
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.All;
});

//Rate limiting
builder.Services.AddApiRateLimiting(serverConfiguration);

Expand Down Expand Up @@ -137,6 +142,16 @@
Log.Information("Preflight checks passed");

// Configure the HTTP request pipeline.
if (serverConfiguration.PathBase != null)
{
app.UsePathBase(serverConfiguration.PathBase);
}

if (serverConfiguration.UseForwardedHeaders)
{
app.UseForwardedHeaders();
}

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
Expand Down
2 changes: 1 addition & 1 deletion SS14.MapServer/SS14.MapServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 5dd42b8

Please sign in to comment.