Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ivann14 committed Feb 15, 2024
0 parents commit 4747df7
Show file tree
Hide file tree
Showing 88 changed files with 1,193 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./proxy
push: true
tags: ivann14dev/ssl-offloader:latest
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SSL Offloader

The SSL Offloader is a proxy service that handles SSL/TLS termination for your applications. It offloads the CPU-intensive encryption and decryption tasks from the application server to the proxy server, improving the performance of the application server.

The SSL Offloader creates a self-signed SSL certificate for development purposes. This certificate is not trusted by default, so you'll need to manually import and trust it on your system.

## Example Folder

The `example` folder contains an example setup for the SSL Offloader. It includes a Docker Compose file that sets up the SSL Offloader and an example application, and a `volumes` directory that is used for sharing the SSL certificate between the SSL Offloader and the application.

To use the example setup:

1. Navigate to the `example` directory.
2. Run `docker-compose up -d` to start the SSL Offloader and the example application.
3. The SSL Offloader will create a self-signed SSL certificate and place it in the `volumes` directory.
4. The example application will use this certificate for SSL/TLS termination.

## Importing and Trusting the Certificate

### Windows with .NET CORE SDK installed
Generate your own certificate via .NET SDK then place it in directory that will be mounted to `/certificate-volume`

```bash
dotnet dev-certs https --export-path $PATH_TO_DIRECTORY/dev-certificate.pfx -p $CERTIFICATE_PASSWORD
dotnet dev-certs https --clean --import $PATH_TO_DIRECTORY/dev-certificate.pfx -p $CERTIFICATE_PASSWORD
```

### Windows

1. Open a Command Prompt as Administrator.
2. Navigate to the directory containing the certificate file.
3. Run the following command:

```bash
$pwd = ConvertTo-SecureString -String "your_certificate_password" -Force -AsPlainText
Import-PfxCertificate -FilePath "path_to_your_certificate.pfx" -CertStoreLocation Cert:\LocalMachine\Root -Password $pwd
```

### Mac OS

1. Open Keychain Access.
2. Go to File > Import Items.
3. Navigate to the location of the certificate file, select it, and click Open.
4. In the Keychains list, click Certificates.
5. Double-click the certificate, expand the Trust section, and under When using this certificate, select Always Trust. Providing Your Own SSL Certificate. If you want to use your own SSL certificate instead of the self-signed certificate, you can do so by placing it on the path /certificate-volume/dev-certificate.pfx on your host computer. This path is mounted as a volume in the Docker container, so the SSL Offloader will use your certificate for SSL/TLS termination.
30 changes: 30 additions & 0 deletions example/demo-web/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added example/demo-web/.vs/demo-web/v17/.futdcache.v2
Binary file not shown.
Binary file added example/demo-web/.vs/demo-web/v17/.suo
Binary file not shown.
26 changes: 26 additions & 0 deletions example/demo-web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["demo-web.csproj", "."]
RUN dotnet restore "./././demo-web.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "./demo-web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./demo-web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_HTTP_PORTS=8081
ENV ASPNETCORE_HTTPs_PORTS=
ENTRYPOINT ["dotnet", "demo-web.dll"]
8 changes: 8 additions & 0 deletions example/demo-web/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Microsoft.AspNetCore.Http.Extensions;

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.Map("/{**catchall}", (HttpContext httpContext) => $"Current URL: {httpContext.Request.GetDisplayUrl()}");

app.Run();
23 changes: 23 additions & 0 deletions example/demo-web/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"profiles": {
"demo-web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:51816;http://localhost:51817"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
}
}
34 changes: 34 additions & 0 deletions example/demo-web/bin/Debug/net8.0/demo-web.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"demo-web/1.0.0": {
"dependencies": {
"Microsoft.VisualStudio.Azure.Containers.Tools.Targets": "1.19.5"
},
"runtime": {
"demo-web.dll": {}
}
},
"Microsoft.VisualStudio.Azure.Containers.Tools.Targets/1.19.5": {}
}
},
"libraries": {
"demo-web/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.VisualStudio.Azure.Containers.Tools.Targets/1.19.5": {
"type": "package",
"serviceable": true,
"sha512": "sha512-Kaa1rBZdJFq5A0qgAcl6Bmk/UqLXTq9acEqxUlPEBA8oscmakLfkvuSXfG7Wa9t1/keaT85EuuDNgOo+Z9VYOQ==",
"path": "microsoft.visualstudio.azure.containers.tools.targets/1.19.5",
"hashPath": "microsoft.visualstudio.azure.containers.tools.targets.1.19.5.nupkg.sha512"
}
}
}
Binary file added example/demo-web/bin/Debug/net8.0/demo-web.dll
Binary file not shown.
Binary file added example/demo-web/bin/Debug/net8.0/demo-web.exe
Binary file not shown.
Binary file added example/demo-web/bin/Debug/net8.0/demo-web.pdb
Binary file not shown.
19 changes: 19 additions & 0 deletions example/demo-web/bin/Debug/net8.0/demo-web.runtimeconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
16 changes: 16 additions & 0 deletions example/demo-web/demo-web.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>demo_web</RootNamespace>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions example/demo-web/demo-web.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions example/demo-web/demo-web.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "demo-web", "demo-web.csproj", "{44E0CA53-BF3D-4969-B6EC-101CFA25ADD7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{44E0CA53-BF3D-4969-B6EC-101CFA25ADD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44E0CA53-BF3D-4969-B6EC-101CFA25ADD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44E0CA53-BF3D-4969-B6EC-101CFA25ADD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44E0CA53-BF3D-4969-B6EC-101CFA25ADD7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {204F2F15-57D4-48F7-802A-2979F799F2F8}
EndGlobalSection
EndGlobal
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
Binary file added example/demo-web/obj/Debug/net8.0/apphost.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions example/demo-web/obj/Debug/net8.0/demo-web.AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("demo-web")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("demo-web")]
[assembly: System.Reflection.AssemblyTitleAttribute("demo-web")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fa99c90574d82fe88f510752fdd291c0c4ccbd3bbbd75dbbc55d296391447bc9
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb = true
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = demo_web
build_property.RootNamespace = demo_web
build_property.ProjectDir = C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.RazorLangVersion = 8.0
build_property.SupportLocalizedComponentNames =
build_property.GenerateRazorMetadataSourceChecksumAttributes =
build_property.MSBuildProjectDirectory = C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web
build_property._RazorSourceGeneratorDebug =
17 changes: 17 additions & 0 deletions example/demo-web/obj/Debug/net8.0/demo-web.GlobalUsings.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// <auto-generated/>
global using global::Microsoft.AspNetCore.Builder;
global using global::Microsoft.AspNetCore.Hosting;
global using global::Microsoft.AspNetCore.Http;
global using global::Microsoft.AspNetCore.Routing;
global using global::Microsoft.Extensions.Configuration;
global using global::Microsoft.Extensions.DependencyInjection;
global using global::Microsoft.Extensions.Hosting;
global using global::Microsoft.Extensions.Logging;
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Net.Http.Json;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Empty file.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11d05509a3fc0083f069db782b6b10e83252898236b9d72d83fe26b226aedb1e
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\bin\Debug\net8.0\demo-web.exe
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\bin\Debug\net8.0\demo-web.deps.json
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\bin\Debug\net8.0\demo-web.runtimeconfig.json
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\bin\Debug\net8.0\demo-web.dll
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\bin\Debug\net8.0\demo-web.pdb
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.AssemblyInfoInputs.cache
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.AssemblyInfo.cs
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.csproj.CoreCompileInputs.cache
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.MvcApplicationPartsAssemblyInfo.cache
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets.build.json
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets.development.json
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets\msbuild.demo-web.Microsoft.AspNetCore.StaticWebAssets.props
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets\msbuild.build.demo-web.props
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets\msbuild.buildMultiTargeting.demo-web.props
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets\msbuild.buildTransitive.demo-web.props
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\staticwebassets.pack.json
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\scopedcss\bundle\demo-web.styles.css
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.dll
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\refint\demo-web.dll
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.pdb
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\demo-web.genruntimeconfig.cache
C:\Users\IvanN\AelGithubRepo\ssl-offloader\demo-web\obj\Debug\net8.0\ref\demo-web.dll
Binary file added example/demo-web/obj/Debug/net8.0/demo-web.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a0be033c067b1445eb8891264728f2dfb547ed12beffc22936213768d283e125
Binary file added example/demo-web/obj/Debug/net8.0/demo-web.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions example/demo-web/obj/Debug/net8.0/staticwebassets.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Version": 1,
"Hash": "SUF8PmNSAAjnv1zugzAepfolEko2vbUvmmsrH0c6aqY=",
"Source": "demo-web",
"BasePath": "_content/demo-web",
"Mode": "Default",
"ManifestType": "Build",
"ReferencedProjectsConfiguration": [],
"DiscoveryPatterns": [],
"Assets": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="Microsoft.AspNetCore.StaticWebAssets.props" />
</Project>
Loading

0 comments on commit 4747df7

Please sign in to comment.