OPNsense Forum

English Forums => Development and Code Review => Topic started by: pheinrich on January 02, 2022, 02:01:12 PM

Title: Nginx plugin SNI Hostname Mapping
Post by: pheinrich on January 02, 2022, 02:01:12 PM
Hi,

I need to write a SNI Hostname Mapping containing a regex for my nginx stream config.


     # upstream maps
     map $ssl_preread_server_name $hostmap810accf68e0940739a1a2e6e120da638 {
         ~(.*).xxx.example.com upstream648aa196e04c4ad89c034af56d947d20;
         default upstream99238aa963f043548157e74820e3cb70;

     }


But for some reason the UI does not allow to insert something thats not a hostname.
If I change this manually in /usr/local/etc/nginx/nginx.conf and restart all is ok, so it's supported by nginx.

I searched around and tried to find whats going on here $nginx->serializeToConfig(); but I have no glue where the hostname validation is applied.

The Nginx SettingsController.php extends ApiMutableModelControllerBase but where is the assumption that hostname inside the sni_mapping_table should be a valid hostname?

https://github.com/opnsense/plugins/issues/2733
Title: Re: Nginx plugin SNI Hostname Mapping
Post by: Fright on January 02, 2022, 04:42:33 PM
hi!
https://github.com/opnsense/plugins/blob/142ea68c0649b69df9713a900afb8406835ba770/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml#L1081
field type is defined as HostnameField so it will not allow regex
type="TextField" may work imho
Title: Re: Nginx plugin SNI Hostname Mapping
Post by: pheinrich on January 02, 2022, 05:18:39 PM
Thank you! All working now. Have created a pull request to change that type.