Let's Encrypt Certificate improvements

Options
PeterUK
PeterUK Posts: 4,674 image  Guru Member
250 Answers 2500 Comments Friend Collector Eighth Anniversary
edited July 29 in Security Ideas

So this is great to see and hope to see in switches but I would like a custom change to the way HTTP works as I have Nginx which can do the redirect of like zyxel-router1.ddns.net (soon to be change to zyxel-router1.bridgemode.network) without affecting like server.bridgemode.network

All thats needed is for the FLEX H to listen on a LAN interface for port 80 and Nginx can proxy on WAN to the internal LAN but for security on another port then 80 only when renew happens so what happens is the renew starts USG listens port 88 traffic port 80 is sent to Nginx then Nginx proxy to port 88 to USG and the challenge is complete port 88 no longer listened on.

2
2 votes

Declined · Last Updated

Comments

  • Maverick87
    Maverick87 Posts: 319 image  Master Member
    Zyxel Certified Network Administrator - WLAN Zyxel Certified Network Administrator - Nebula Zyxel Certified Network Administrator - Security Zyxel Certified Sales Associate
    Options

    Hi @PeterUK,

    You cannot NAT the 88 port to 80?

  • PeterUK
    PeterUK Posts: 4,674 image  Guru Member
    250 Answers 2500 Comments Friend Collector Eighth Anniversary
    edited July 29
    Options

    I don't think you understand how Nginx works or what it is maybe?

    so its like this I run a PC server it has a web server on port 443 for HTTPS and port 8080 for HTTP I also have a DNS-over-HTTPS with a Let's Encrypt then have nginx on where the web server is thats on port 80 the config (the important bits) is like this:

    }
    server {
    listen 80;
    server_name server.bridgemode.network;
    location / {
    proxy_pass http://localhost:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
    }
    server {
    listen 80;
    server_name dns.bridgemode.network;
    location / {
    proxy_pass http://192.168.138.13:80;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
    }

    So anything server.bridgemode.network goes to the web server on port 8080 and anything dns.bridgemode.network goes to the DNS-over-HTTPS server when certbot does setup or renew incoming traffic to port 80 that how the Certificate challenge is done will be for dns.bridgemode.network

    as Nginx is a proxy traffic will be like this

    source IP > WAN IP:80 >Nginx> 192.168.138.2 > 192.168.138.13:80 to DNS-over-HTTPS server when it opens port 80 for challenge 

    so what I would do is add to the above setup like

    server {
    listen 80;
    server_name zyxel-router1.bridgemode.network;
    location / {
    proxy_pass http://192.168.138.100:88;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    so

    source IP > WAN IP:80 >Nginx> 192.168.138.2 > 192.168.138.100:88 to USG

    the reason to change port to like 88 is the UI thats on 80 for the USG I don't think the Certificate challenge will know that Nginx changed the port as returning traffic will come from source 80 by Nginx.

  • Zyxel_Tina
    Zyxel_Tina Posts: 965 image  Zyxel Employee
    Zyxel Certified Network Administrator - Security Zyxel Certified Network Administrator - Switch 100 Answers 500 Comments
    Options

    Hi @PeterUK,

    Thanks for the detailed information!

    Regarding your request, we would like to clarify two points:

    1. The HTTP-01 challenge validation must occur on port 80. This is a requirement of the ACME standard itself (not specific to our implementation), so we're unable to offer a configurable port for the challenge listener.
    2. About port 80 being persistently exposed, please rest assure that the USG FLEX H does not keep port 80 open at all times. It's automatically opened only for the short window needed to complete the Let's Encrypt renewal (typically just a couple of minutes), and is closed again automatically once validation is complete. Therefore, there is no long-term exposure issue to address, and no workaround is required.

    We appreciate your understanding.

    Zyxel Tina

  • PeterUK
    PeterUK Posts: 4,674 image  Guru Member
    250 Answers 2500 Comments Friend Collector Eighth Anniversary
    edited August 17
    Options

    Hi Tina

    Yes I get it needs port 80 but do you understand how how Nginx works?
    https://nginx.org/

    I did a test of my method and it works HTTP-01 challenge validation will not know port 80 was changed the challenge comes in on port 80 to Nginx then proxy by port 88 then USG maps it back to 80 to my linux mint that did the challenge but really it should work without mapping from 88 to 80?

    I think there can be security issue with port 80 to FLEX H even if you don't know it yet unless you have coded for when port 80 is waiting for the challenge you block UI access for port 80 which is why I would like the port to be changeable so that Nginx can proxy the given domain from port 80 to another port on the USG for the challenge to be done.

    as another side question is the HTTP-01 challenge only on External or can it work on General or Internal if proxyed to the gateway

    Nginx would allow port 80 to be open without downtime when doing the challenge

    server {
    listen 80;
    server_name dns.bridgemode.network;
    location / {
    proxy_pass http://192.168.138.13:80;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
    }
    server {
    listen 80;
    server_name home-assistant.bridgemode.network;
    location / {
    proxy_pass http://192.168.138.12:88;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }
    }
    server {
    listen 80;
    server_name hub5.bridgemode.network;
    location / {
    proxy_pass http://192.168.138.12:88;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    }

    so like I have a dns.bridgemode.network on linux mint DoH Server Certificate that the challenge only does for the given subdomain by Let's Encrypt
    .

    And home-assistant.bridgemode.network and hub5.bridgemode.network that the proxy to 192.168.138.12 port 88 to FLEX 700H Secondary IP where I do

    Screenshot 2026-08-17 114717.png Screenshot 2026-08-17 115046.png

    and get a Certificate there for them subdomain by Let's Encrypt to it Nginx config

    so what I would like is a just a optional port change that can close itself when its do and is only for the challenge on what interface please it really will work and Nginx takes case of the inbound port 80 handing.

  • PeterUK
    PeterUK Posts: 4,674 image  Guru Member
    250 Answers 2500 Comments Friend Collector Eighth Anniversary
    Options
  • PeterUK
    PeterUK Posts: 4,674 image  Guru Member
    250 Answers 2500 Comments Friend Collector Eighth Anniversary
    Options

    And also using Nginx in this way solves completely the how do we Certificate for many devices that only has one WAN IP for port 80 like other USG, switches and AP's