You can go to the home center and get some pipe fence fittings that go around the pipe and then screw to the rail of the fence. You should have about three rails. Screw the adapters to the fence with treated lag bolts, this should work.
Now if the post is too far from the rails of the fence, you need to re consider this task. The post needs to be within an inch or two of the rails.