There is no way to control the ordering of rules/actions. This is incredibly important, especially if implementing http2. The actions seem to be put into the config in a random order.
This is more a general issue in the core GUI/framework. A fix was committed in https://github.com/opnsense/core/issues/1689 and should be available in OPNsense 18.7.
This bug still exists after the fix you mentioned, running 18.1.8. This is a regression/bug, not an enhancement. In the previous haproxy interface (the one that came from the pfsense lineage of code) you had control over the order of the rules.
Before saving (notice the rule that starts with 999 is at the end). This is from the edit page for a public service.:

After saving (now its in the middle):

Also note that this method (if it worked) of controlling the ordering of rules is only really usable for trivial cases. There is no way to reorder the entries in the rules box. So if you are using anything more then a couple rules it becomes very tedious and unusable as you are required to rebuild the list up to the point you want to change.
This was caused by some change related to https://github.com/opnsense/plugins/issues/208
This is a regression/bug, not an enhancement. In the previous haproxy interface (the one that came from the pfsense lineage of code)
It's not a regression, because the HAProxy plugin has been written from scratch, no pfSense plugin code exists in OPNsense.
This was caused by some change related to #208
Nope.
Note that I said the fix will be available in OPNsense 18.7.
Sorry for the misunderstanding. I thought since this started out as a fork of pfsense things originally came from there at some point. So its more of a feature lost (when migrating my setup).
Also was confused with the release of 18.1.7, didn't realize you meant something different.
Ok, finally tested on 18.7.1. Still unable to order the rules
@AdSchellevis, @ghostwheel42: Let's move the discussion to this issue.
@AdSchellevis wrote in https://github.com/opnsense/plugins/issues/769#issuecomment-413111958:
@ghostwheel42 I'm not 100% we're looking at the same case, but I checked "Public Services" and traced the rules there, they use a ModelRelationField which is isn't (and never was) sorted by the order in the selectbox.
So... if we're looking at the same field/type, I'm afraid @fraenki made the false assumption that those are ordered by input and this is actually a bug in the HAProxy plugin. I'm not sure why ordering matters here, but if it does and needs the field type that's in there now, I can't fix it at the moment.
for reference : https://github.com/opnsense/core/blob/18.7.1/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php#L196-L203
Indeed, I was always assuming that these fields are ordered by input. And in most cases this seems to be true, I'm heavily relying on the sort order and it seems to never change on my existing setups. Some of these setups exist since 2016 and still work as expected (read: sort order does not change).
I can't find a way to properly reproduce this, what are you doing that messes up the sort order?
maybe a weight on the rule could be an easy fix to achieve the desired behaviour, but that's just a possible solution for the issue. maybe it's better to open a new feature request and discuss with @fraenki
I don't like this aproach. It's clumsy. This is not something that the _user_ should solve by specifying a "priority", but instead the _GUI_ should allow sorting. Has anyone ideas for more sophisticated solutions? Maybe add some sorting attributes to ModelRelationField?
refs #725
@franki: Hi, and sorry for the late answer.
You are correct: Nothing messes up the sort order.
But you can't re-order rules, after creation. Rules always remain in creation order. If you want to reorder, you have to delete and recreate the rule.
The rules seem to have an implicit "weight" (the creation time).
So I think this issue is an enhancement request and not a bug. There should be an re-orderable input to put rules in the order you want (drag and drop?). It also could be used for certificates, as the first one will be used in non strict-sni setups as default.
@ghostwheel42 Thanks for the clarification! @fichtner suggested to use a tokenize2 feature for this:
https://github.com/zellerda/Tokenize2/blob/eaf04ff2468dbd2d876f946860d73675eb93c098/tokenize2.js#L85
Any idea how to properly make this configurable in the OPNsense MVC framework? Because I don't :)
It requires an unfortunately stale library called „jquery ui“ to work. If it worked it would probably be ok as on for all current fields. I don’t see a problem in reordering. Cc @adschellevis what do you think about this dependency?
@fichtner I rather keep jQuery UI out, it wouldn't solve the issue anyway since the order isn't determined by the selected items in the list anyway.
For ordering model relations, yep.
@fraenki I've created an issue/question for you here https://github.com/dragonofmercy/Tokenize2/issues/62, we will pickup the model code to support ordering at our end. That's basically all I can do for you at the moment.
@AdSchellevis A fix was comitted upstream. I'd love to get this done for an early 19.1.x release. What are the next steps? Merge the new tokenize2 version?
@fraenki Probably pull in the new version (when available) and adjust our template, if you create an issue in core, I’ll try to look at this at the end of next week.
This will be fixed in the upcoming release os-haproxy 2.15. Thanks to Ad!
@fraenki What happens to existing rules? The current order will remain unchanged?
I need to upgrade an production server with several rules (which is a pain to maintain without this feature), but I am worried about the side effects.
What happens to existing rules? The current order will remain unchanged?
It will remain unchanged. At least according to my own testing... :)