opnsense / plugins

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

www/caddy Specify listening port #4065

Closed PacFox closed 5 days ago

PacFox commented 5 days ago

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

Is your feature request related to a problem? Please describe. I saw from the Caddy documentation (https://caddyserver.com/docs/caddyfile/options#https-port) that it should be possible to change the ports it will listen on in the Caddyfile however when installed in Opnsense it's commented as auto-generated.

Describe the solution you'd like I would like to be able to set the Caddy's HTTPS and HTTP listening ports similar to how you can with Unbound's DNS listening port.

Describe alternatives you've considered I thought about using a container to run it separately where I'd have full control though it would be better if it could just run whenever the router is running.

Monviech commented 5 days ago

You can use import statements to change whatever you want. Here is an example:

https://docs.opnsense.org/manual/how-tos/caddy.html#advanced-bind-caddy-to-specific-interface

https://docs.opnsense.org/manual/how-tos/caddy.html#using-custom-configuration-files

Edit: You would have to explain to me why you would want that. What is the usecase to run the Caddy ports on 8080 and 8443 for example?

You would need to port forward port 80 and 443 to 8080 and 8443 then, which makes the point to change these ports moot.

PacFox commented 5 days ago

@Monviech Thanks for the info, not sure how I missed reading about adding custom config files but I've now got it sorted to the use the specific ports. My main reason is that I wanted the local hostname/ip to go still to Opnsense dashboard (without specifying ports) and only the external domains through the reverse proxy. Nevertheless as it's working now I'll close this request.

Monviech commented 5 days ago

@PacFox Oh okay. Great that you got it working. When more people request it in the future I might add it to the GUI. I'm just a little reluctant about it, just as with offering binding to a specific IP address, since I have a high priority to avoid unintended user error.

EDIT: This can also be valid option if the WebGUI should still respond on 443:

https://docs.opnsense.org/manual/how-tos/caddy.html#reverse-proxy-the-opnsense-webgui

PacFox commented 5 days ago

@Monviech That's fair enough, never any fun running into that. Thanks very much for your time and knowledge with this all.

Monviech commented 2 days ago

@PacFox I have looked at it again and see no reason not to offer it in the GUI. I have attached a PR.

PacFox commented 1 day ago

Thanks @Monviech, I'll try it out once the next update is out.