Compare commits

...

2 Commits

Author SHA1 Message Date
Simon 6c8fdf875f Update nginx
continuous-integration/drone/push Build is passing Details
2021-10-03 03:52:45 +01:00
Simon 55486aaedd Im in? 2021-10-03 03:48:30 +01:00
2 changed files with 17 additions and 9 deletions

View File

@ -4,10 +4,19 @@ using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using System.Collections;
var builder = WebApplication.CreateBuilder(args);
var Configuration = builder.Configuration;
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddControllers();
@ -31,12 +40,7 @@ builder.Services.AddAuthentication(options => {
var app = builder.Build();
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
RequireHeaderSymmetry = false,
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseForwardedHeaders();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())

View File

@ -27,7 +27,7 @@ http {
#gzip on;
# include /etc/nginx/conf.d/*.conf;
# include /etc/nginx/conf.d/*.conf;
server {
listen 9000;
@ -58,10 +58,14 @@ http {
}
location / {
# Do preserve this
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
# again dont overwrite this
#proxy_set_header X-Real-IP $remote_addr;
# this just seems to append another ip ie <host>, <proxy>
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Preserve the scheme as https if behind another proxy
#proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1