Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Route53 DNS Provider added + Dark Mode GUI fix (#86)
Browse files Browse the repository at this point in the history
* Update README.md

Adjusted build to include all DNS Providers that exist so it's easer to add new ones later.

* Update Caddy.xml

Add route53 to model.

* Update dnsprovider.xml

Added help text for Route53

* Update Caddyfile

added elif for route53 to add the access_key_id and secret_access_key

* Built os-caddy-1.4.3 and caddy-2.7.6_3. Added Route53 to GUI. Added all possible DNS Providers to caddy binary. Rebilt os-caddy for 24.1 ABI.

* Delete usr/local/bin/caddy

Binary is not needed here.

* Update README.md

* Update general.volt

Cleaned up general view to fix rendering in dark mode and to make it more in line with other modern views in OPNsense.

* Update general.volt

Small typo fix.

* Update reverse_proxy.volt

Fixed hard coded color for dark mode support. Adjusted Padding of headlines. Modernized Apply button.

* Update dnsprovider.xml

Changed TlsDnsSecretApiKey field from advanced to standard since more than one DNS Provider uses it now.

* Built os-caddy-1.4.4. Fixed a few GUI when using Dark Mode.

* Update README.md

Changed SHA256 of caddy binary since it was rebuilt. Tested on latest OPNsense Version 24.1.1 added.

* Built os-caddy-1.4.4. Fixed a few GUI when using Dark Mode.
  • Loading branch information
Monviech authored Feb 8, 2024
1 parent 32c52bd commit dd2a674
Show file tree
Hide file tree
Showing 18 changed files with 372 additions and 56 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
- Automatic Let's Encrypt and ZeroSSL Certificates without configuration with HTTP-01 and TLS-ALPN-01
- ACME DNS-01 challenge with configuration (requires supported DNS Provider)
- Dynamic DNS (DynDns) with configuration (requires supported DNS Provider)
- Supported DNS Providers:
- ```cloudflare, duckdns, digitalocean, dnspod, hetzner, godaddy, gandi, vultr, ionos, desec, porkbun```
- Supported DNS Providers in GUI:
- ```cloudflare, duckdns, digitalocean, dnspod, hetzner, godaddy, gandi, vultr, ionos, desec, porkbun, route53```
- Use custom certificates from OPNsense certificate store
- Normal domains, wildcard domains and subdomains
- Access Lists to restrict access based on static networks
Expand All @@ -34,10 +34,10 @@

# How to install:
##### DISCLAIMER: Even though I use this productively on multiple OPNsense Firewalls (and also a HA pair with config sync), I give no guarantee whatsoever. Please read the license file for the full disclaimer. Most code is in line with OPNsense integrated functions. Some parts were developed with the use of AI assistance (ChatGPT4 and Copilot).
##### Tested by myself on DEC740 Hardware with OPNsense CE 23.7.12-amd64, and on DEC2750 Hardware in HA with OPNsense BE 23.10.1-amd64.
##### Tested on DEC740 Hardware with OPNsense CE 24.1.1-amd64, and on DEC2750 Hardware in HA with OPNsense BE 23.10.1-amd64.
##### Caddy Version:
- ```v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=```
- ```SHA256 (/usr/local/bin/caddy) = 68973bbae59c3ba8d5210168c01fce661f36645699fd722d90032177a83d1d1a```
- ```SHA256 (/usr/local/bin/caddy) = 9722999d0c5a6bb9d82217d384f744f61f746086526112fc38c775bef619a440```

Connect to your OPNsense via SSH, select option 8 to get into the shell, and invoke the following commands:
```
Expand All @@ -46,7 +46,7 @@ fetch -o /usr/local/etc/pkg/repos/os-caddy-plugin.conf https://os-caddy-plugin.p
```
pkg update
```
- **Attention** - If you have other (community) repositories installed that serve the caddy binary, some features might not work. Make sure you get caddy-2.7.6_2 from my repository. There are extra features compiled in.
- **Attention** - If you have other (community) repositories installed that serve the caddy binary, some features might not work. Make sure you get caddy-2.7.6_3 from my repository. There are extra features compiled in.
- Afterwards the "os-caddy" plugin can be installed from the OPNsense System - Firmware - Plugins, search for "os-caddy".

# How to use Caddy after the installation:
Expand Down
Binary file not shown.
Binary file modified os-caddy-plugin/FreeBSD:13:amd64/meta.pkg
Binary file not shown.
Binary file not shown.
Binary file modified os-caddy-plugin/FreeBSD:13:amd64/packagesite.pkg
Binary file not shown.
6 changes: 3 additions & 3 deletions usr/local/bin/+MANIFEST
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "caddy",
"version": "2.7.6_2",
"version": "2.7.6_3",
"comment": "Caddy web server",
"desc": "Caddy 2 is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go",
"www": "https://caddyserver.com",
Expand All @@ -13,7 +13,7 @@
"licenses": ["APACHE20"],
"files": {
"/usr/local/bin/caddy": {
"checksum": "68973bbae59c3ba8d5210168c01fce661f36645699fd722d90032177a83d1d1a",
"checksum": "9722999d0c5a6bb9d82217d384f744f61f746086526112fc38c775bef619a440",
"username": "root",
"groupname": "wheel",
"perm": "0555"
Expand All @@ -25,7 +25,7 @@
"checksum": "2dca659dc8846be25ab729554fe067dba90ca252314b73f6c6dbaa95bbb72d4e"
},
"/usr/local/share/licenses/caddy-2.7.6_2/catalog.mk": {
"checksum": "be81e84c82648a4cf381bb95eace48843870fca4297773c1e71ffa50196b04ea"
"checksum": "61341e9179bf9dcd653753202fba05b025befdf49f0a93e7a03f16d766ebcd90"
}
}
}
310 changes: 309 additions & 1 deletion usr/local/bin/README.md

Large diffs are not rendered by default.

Binary file removed usr/local/bin/caddy
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ _LICENSE=APACHE20
_LICENSE_NAME=Apache License 2.0
_LICENSE_PERMS=dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
_LICENSE_GROUPS=APACHE OSI
_LICENSE_DISTFILES=caddy-2.7.6_2.pkg
_LICENSE_DISTFILES=caddy-2.7.6_3.pkg

2 changes: 1 addition & 1 deletion usr/plugins/devel/caddy/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PLUGIN_NAME= caddy
PLUGIN_VERSION= 1.4.2
PLUGIN_VERSION= 1.4.4
PLUGIN_DEPENDS= caddy
PLUGIN_COMMENT= Easy to configure Reverse Proxy based on Caddy with Automatic HTTPS and Dynamic DNS
PLUGIN_MAINTAINER= [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
<id>caddy.general.TlsDnsApiKey</id>
<label>DNS API Key</label>
<type>text</type>
<help><![CDATA[This is the standard field for the API Key. Enter the API key for the selected DNS provider. Leave this empty if no DNS provider is set.]]></help>
<help><![CDATA[This is the standard field for the API Key. Enter the API key for the selected DNS provider. For Route53 enter your "access_key_id" here. For Porkbun enter your "api_key" here. Leave this empty if no DNS provider is set.]]></help>
</field>
<field>
<id>caddy.general.TlsDnsSecretApiKey</id>
<label>DNS Secret API Key</label>
<type>text</type>
<help><![CDATA[A few DNS providers like porkbun also need a Secret API Key set. Leave this empty if other or no DNS providers are set.]]></help>
<advanced>true</advanced>
<help><![CDATA[For Route53 enter your "secret_access_key" here. For Porkbun enter your "api_secret_key" here. Leave this empty if other or no DNS providers are set.]]></help>
</field>
<field>
<id>caddy.general.DynDnsSimpleHttp</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ionos>IONOS</ionos>
<desec>Desec</desec>
<porkbun>Porkbun</porkbun>
<route53>Route53</route53>
</OptionValues>
</TlsDnsProvider>
<TlsDnsApiKey type="TextField">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,32 @@
</ul>

<!-- Tab Content -->
<div style="background-color: white; padding: 10px; border: 1px solid #ddd;">
<div class="tab-content">

<!-- General Tab -->
<div id="generalTab" class="tab-pane active">
<div class="content">
<h1>General Settings</h1>
{{ partial("layout_partials/base_form", ['fields': generalForm, 'action': '/ui/caddy/general', 'id': 'frm_GeneralSettings']) }}
</div>
</div>

<!-- DNS Provider Tab -->
<div id="dnsProviderTab" class="tab-pane">
<div class="content">
<h1>DNS Provider Settings</h1>
{{ partial("layout_partials/base_form", ['fields': dnsproviderForm, 'action': '/ui/caddy/general', 'id': 'frm_GeneralSettings']) }}
</div>
</div>
<div class="tab-content content-box">
<!-- General Tab -->
<div id="generalTab" class="tab-pane fade in active">
{{ partial("layout_partials/base_form", ['fields': generalForm, 'action': '/ui/caddy/general', 'id': 'frm_GeneralSettings']) }}
</div>
<!-- DNS Provider Tab -->
<div id="dnsProviderTab" class="tab-pane fade">
{{ partial("layout_partials/base_form", ['fields': dnsproviderForm, 'action': '/ui/caddy/general', 'id': 'frm_GeneralSettings']) }}
</div>
</div>

<div style="margin-top: 20px; width: 100%; background-color: white; padding: 5px; border: 1px solid #ddd;">
<!-- Reconfigure Button with Pre-Action -->
<button class="btn btn-primary" id="reconfigureAct"
data-endpoint="/api/caddy/service/reconfigure"
data-label="{{ lang._('Apply') }}"
data-error-title="{{ lang._('Error reconfiguring Caddy') }}"
type="button"
><b>Apply</b></button>
</div>
<section class="page-content-main">
<div class="content-box">
<div class="col-md-12">
<br/>
<!-- Reconfigure Button with Pre-Action -->
<button class="btn btn-primary" id="reconfigureAct"
data-endpoint="/api/caddy/service/reconfigure"
data-label="{{ lang._('Apply') }}"
data-error-title="{{ lang._('Error reconfiguring Caddy') }}"
type="button"
></button>
<br/><br/>
</div>
</div>
</section>

<script type="text/javascript">
$(document).ready(function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

<!-- Reverse Proxy Tab -->
<div id="domainsTab" class="tab-pane fade in active">
<div style="background-color: white; padding: 10px; border: 1px solid #ddd;">
<div style="padding-left: 16px;">
<!-- Reverse Proxy -->
<h1>Domains</h1>
<div style="display: block;"> <!-- Common container -->
Expand Down Expand Up @@ -131,7 +131,7 @@
</table>
</div>
</div>
<div style="background-color: white; padding: 10px; margin-top: 20px; border: 1px solid #ddd;">
<div style="padding-left: 16px;">
<!-- Subdomains -->
<h1>Subdomains</h1>
<div style="display: block;"> <!-- Common container -->
Expand Down Expand Up @@ -168,7 +168,7 @@

<!-- Handle Tab -->
<div id="handlesTab" class="tab-pane fade">
<div style="background-color: white; padding: 10px; border: 1px solid #ddd;">
<div style="padding-left: 16px;">
<h1>Handlers</h1>
<div style="display: block;"> <!-- Common container -->
<table id="reverseHandleGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogHandle">
Expand Down Expand Up @@ -209,7 +209,7 @@
<!-- New Combined Access Tab -->
<div id="accessTab" class="tab-pane fade">
<!-- Access Lists Section -->
<div style="background-color: white; padding: 10px; border: 1px solid #ddd;">
<div style="padding-left: 16px;">
<h1>Access Lists</h1>
<div style="display: block;">
<table id="accessListGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogAccessList">
Expand Down Expand Up @@ -239,7 +239,7 @@
</div>

<!-- Basic Auth Section -->
<div style="background-color: white; padding: 10px; margin-top: 20px; border: 1px solid #ddd;">
<div style="padding-left: 16px;">
<h1>Basic Auth</h1>
<div style="display: block;">
<table id="basicAuthGrid" class="table table-condensed table-hover table-striped" data-editDialog="DialogBasicAuth">
Expand Down Expand Up @@ -269,14 +269,20 @@
</div>

<!-- Reconfigure Button -->
<div style="margin-top: 20px; width: 100%; background-color: white; padding: 5px; border: 1px solid #ddd;">
<button class="btn btn-primary" id="reconfigureAct"
data-endpoint="/api/caddy/service/reconfigure"
data-label="{{ lang._('Apply') }}"
data-error-title="{{ lang._('Error reconfiguring Caddy') }}"
type="button"
><b>Apply</b></button>
</div>
<section class="page-content-main">
<div class="content-box">
<div class="col-md-12">
<br/>
<button class="btn btn-primary" id="reconfigureAct"
data-endpoint="/api/caddy/service/reconfigure"
data-label="{{ lang._('Apply') }}"
data-error-title="{{ lang._('Error reconfiguring Caddy') }}"
type="button"
></button>
<br/><br/>
</div>
</div>
</section>

{{ partial("layout_partials/base_dialog",['fields':formDialogReverseProxy,'id':'DialogReverseProxy','label':lang._('Edit Reverse Proxy Domain')])}}
{{ partial("layout_partials/base_dialog",['fields':formDialogSubdomain,'id':'DialogSubdomain','label':lang._('Edit Reverse Proxy Subdomain')])}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@

{% if dnsProvider and dnsProvider != "none" and dnsApiKey and dynDnsDomains|length > 0 %}
dynamic_dns {
{% if dnsProvider in ['porkbun', 'desec'] %}
{% if dnsProvider in ['porkbun', 'desec', 'route53'] %}
provider {{ dnsProvider }} {
{% if dnsProvider == 'porkbun' %}
api_key {{ dnsApiKey }}
api_secret_key {{ dnsSecretApiKey }}
{% elif dnsProvider == 'desec' %}
token {{ dnsApiKey }}
{% elif dnsProvider == 'route53' %}
access_key_id {{ dnsApiKey }}
secret_access_key {{ dnsSecretApiKey }}
{% endif %}
}
{% else %}
Expand Down Expand Up @@ -125,14 +128,17 @@
# Reverse Proxy Configuration
{% macro tls_configuration(dnsProvider, dnsApiKey, customCert, dnsChallenge, dnsSecretApiKey) %}
{% if dnsChallenge == "1" and dnsProvider and dnsProvider != "none" and dnsApiKey %}
{% if dnsProvider in ['porkbun', 'desec'] %}
{% if dnsProvider in ['porkbun', 'desec', 'route53'] %}
tls {
dns {{ dnsProvider }} {
{% if dnsProvider == 'porkbun' %}
api_key {{ dnsApiKey }}
api_secret_key {{ dnsSecretApiKey }}
{% elif dnsProvider == 'desec' %}
token "{{ dnsApiKey }}"
{% elif dnsProvider == 'route53' %}
access_key_id {{ dnsApiKey }}
secret_access_key {{ dnsSecretApiKey }}
{% endif %}
}
}
Expand Down

0 comments on commit dd2a674

Please sign in to comment.