opnsense / plugins

OPNsense plugin collection
https://opnsense.org/
BSD 2-Clause "Simplified" License
839 stars 628 forks source link

Caddy fails to start when HTTPS is disabled for the web gui #4288

Open sdellysse opened 3 days ago

sdellysse commented 3 days ago

Problem: When System: Settings: Administration: Web GUI: Protocol is set to HTTP, and System: Settings: Administration: Web GUI: TCP Port is set to 81, the caddy server will fail to start. I fixed this by changing System: Settings: Administration: Web GUI: Protocol to HTTPS, changing System: Settings: Administration: Web GUI: TCP Port to 8443, set System: Settings: Administration: Web GUI: Http Redirect to unchecked.

Expected outcome: when the protocol is http and the port is != 80, caddy should start.

The code that needs to be fixed is somewhere in this block but I haven't had a chance to try to fix it myself: https://github.com/opnsense/plugins/blob/f25a1fa6d54ef53339ab02685ecaf53a8fa5fcbb/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.php#L77C1-L94C6

OPNsense-bot commented 3 days ago

Thank you for creating an issue. Since the ticket doesn't seem to be using one of our templates, we're marking this issue as low priority until further notice.

For more information about the policies for this repository, please read https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md for further details.

The easiest option to gain traction is to close this ticket and open a new one using one of our templates.

Monviech commented 3 days ago

That code you referenced is only a validation to give users feedback that something they configured might collide with what caddy expects.

But caddy is not controlled by that code. I am sure there are a few more configurations that will slip through the cracks.

E.g. if you have another plugin binding ports that Caddy might like to use.

In the Layer 4 module thats included you are able to bind any port that you want, there's no way to validate against all plugins in the system. Caddy will just try to start, and if it can not bind the ports it needs it will fail.