1) Install and Activate FooBar Image Lightbox Plugin
2) Please go to your created page/post gallery of edit mode and select Link to as Media file in gallery settings. Here is a screenshot https://imgur.com/a/y8qk8
Here is output:- https://imgur.com/a/1er2A
Let us know if this helps or need more help please do reply.