Skip to content

Commit

Permalink
Remove https hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
3xjn committed Oct 15, 2024
1 parent 9deaa59 commit 3e8cfe7
Show file tree
Hide file tree
Showing 60 changed files with 959 additions and 57 deletions.
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app

# Set the ASP.NET Core URLs to listen on port 8080
ENV ASPNETCORE_URLS=http://+:8080

# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
Expand All @@ -10,7 +13,6 @@ WORKDIR /app
# Copy project files and restore dependencies
COPY *.csproj .
RUN dotnet restore "TodoAppAPI.csproj"

COPY . .
RUN dotnet build "TodoAppAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build

Expand All @@ -21,17 +23,13 @@ RUN dotnet publish "TodoAppAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /

# Final stage for production
FROM base AS final

# WORKDIR for the app
WORKDIR /app

# Copy published app
COPY --from=publish /app/publish .

# Expose ports 80 and 443
EXPOSE 80
EXPOSE 443

# Expose port 8080
EXPOSE 8080
RUN whoami
RUN env
RUN pwd && ls -l
Expand Down
19 changes: 0 additions & 19 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using LettuceEncrypt;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
Expand Down Expand Up @@ -49,22 +46,6 @@
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Get the PFX file path from the environment variable
var certPem = "/app/cert.pem";
var keyPem = "/app/key.pem";

// Load the PFX certificate
var cert = X509Certificate2.CreateFromPemFile(certPem, keyPem);

// Configure Kestrel to use the certificate
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenAnyIP(443, listenOptions => listenOptions.UseHttps(cert));
});

// Log certificate loading (for debugging)
Console.WriteLine("SSL certificate loaded successfully.");

var app = builder.Build();

if (app.Environment.IsDevelopment())
Expand Down
13 changes: 1 addition & 12 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"https_port": 443,
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:80"
},
"Https": {
"Url": "https://0.0.0.0:443"
}
}
}
"AllowedHosts": "*"
}
Binary file added bin/Release/net8.0/AWSSDK.Core.dll
Binary file not shown.
Binary file added bin/Release/net8.0/AWSSDK.SecurityToken.dll
Binary file not shown.
Binary file added bin/Release/net8.0/AutoMapper.dll
Binary file not shown.
Binary file added bin/Release/net8.0/BouncyCastle.Crypto.dll
Binary file not shown.
Binary file added bin/Release/net8.0/Certes.dll
Binary file not shown.
Binary file added bin/Release/net8.0/DnsClient.dll
Binary file not shown.
Binary file added bin/Release/net8.0/LettuceEncrypt.dll
Binary file not shown.
Binary file not shown.
Binary file added bin/Release/net8.0/Microsoft.OpenApi.dll
Binary file not shown.
Binary file added bin/Release/net8.0/MongoDB.Bson.dll
Binary file not shown.
Binary file added bin/Release/net8.0/MongoDB.Driver.Core.dll
Binary file not shown.
Binary file added bin/Release/net8.0/MongoDB.Driver.dll
Binary file not shown.
Binary file added bin/Release/net8.0/MongoDB.Libmongocrypt.dll
Binary file not shown.
Binary file added bin/Release/net8.0/Newtonsoft.Json.dll
Binary file not shown.
Binary file added bin/Release/net8.0/SharpCompress.dll
Binary file not shown.
Binary file added bin/Release/net8.0/Snappier.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 3e8cfe7

Please sign in to comment.