haxproxy.conf / haxproxy.conf.staging error - Missing LF on last line, truncated

Started by opncya1, February 26, 2025, 10:38:54 PM

Previous topic - Next topic
Disclaimer - I am not positive when this error was present but I believe it may be due to 25.1 as I last updated a setting in haproxy about 2 months ago and I just updated opnsense to 25.1 about a week ago.

Version: 25.1.1

Problem: when going into haproxy to make changes, there is now a warning that reads as follows.  The service starts fine but I can't make any changes and apply it.

There are pending configuration changes that must be applied in order for them to take effect. To review them visit the Config Diff page.

  • Click Test Syntax:


[NOTICE] (60298) : haproxy version is 3.0.8-6036c31
[NOTICE] (60298) : path to executable is /usr/local/sbin/haproxy
[ALERT] (60298) : config : parsing [/usr/local/etc/haproxy.conf.staging:343]: Missing LF on last line, file might have been truncated at position 1.
[ALERT] (60298) : config : Error(s) found in configuration file : /usr/local/etc/haproxy.conf.staging
[ALERT] (60298) : config : Fatal errors found in configuration.

  • Reverted back to a config.xml about 1 hour before I made any changes last night and the DIFF has this message.


--- /usr/local/etc/haproxy.conf   2025-02-25 23:52:06.878159000 -0500
+++ /usr/local/etc/haproxy.conf.staging   2025-02-26 15:32:14.106746000 -0500
@@ -340,4 +340,4 @@
 
 # remote statistics are DISABLED
 
-
+
\ No newline at end of file



  • In haproxy.conf.staging, when I edit the file, I see this is actually at the end but those '@^' symbols may be a lock from opnsense or something.  Deleting the lines doesn't help as it is there again shortly on trying to test/apply the haproxy settings

# remote statistics are DISABLED
   
^@^@^


  • Things that I have tried

- rebooted the node
- stopping/restarting haproxy
- stopping haproxy and adding a new line to haproxy.conf and haproxy.conf.staging
- also tried adding via 'echo "" >> haproxy.conf.staging'

I don't see anything obscure at a glance in my haproxy section in config.xml -- any ideas about what else I could try to fix this issue? 






"Missing LF on last line" . There are online posts about it. But my guess is at some point you were manipulating the config file in a MS Windows machine. LF is a Unix line ending, and that is what haproxy expects.
Solution is to add the missing unix type line ending. I'm pretty sure there are editors that can do it in Windows as well.

Open in vi and save will put an LF at the end of the last line if missing.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)


no, I have never modified any haproxy settings outside of using the opnsense gui.  i've already tried adding newline with vi, nano and echo to no avail -- it's why i posted here in case someone else has seen this issue before.

Quote from: cookiemonster on February 27, 2025, 12:28:44 AM"Missing LF on last line" . There are online posts about it. But my guess is at some point you were manipulating the config file in a MS Windows machine. LF is a Unix line ending, and that is what haproxy expects.
Solution is to add the missing unix type line ending. I'm pretty sure there are editors that can do it in Windows as well.

noticed my secondary node didn't have this config issue after forcing a regenerate while it was carp master.

uninstalled the haproxy plugin on primary node and reinstalled -- the error is gone now!