Hi Daniel. Welcome to the Opto22 Forums! (Love your chosen username!!)
Did you see this post?
The fun part will be, and @greichert might have some ideas, how to skip the Node-RED part and or blend the Node-RED port trick with Codesys to make port 502 an option.