Rewrite rule : custom post type with 2 numeric variiables

add_rewrite_rule() cannot automatically create that permalink structure for you. You should use wp_link_pages_link filter. E.g:

add_filter('wp_link_pages_link', function($link, $i)
{
  global $post, $photo_id;

  if ($photo_id && 'gallery' === $post->post_type)
    $link = $link . "https://wordpress.stackexchange.com/" . intval($photo_id) . "https://wordpress.stackexchange.com/";

  return $link;
}, PHP_INT_MAX, 2);

Then, you must use add_rewrite_tag() to make WordPress aware of photo query string:

add_action('init', function()
{
  add_rewrite_tag('%photo%', '([0-9]+)');
  add_rewrite_rule('^gallery/([^/]+)/([0-9]+)/([0-9]+)/?$', 'index.php?post_type=gallery&name=$matches[1]&page=$matches[2]&photo=$matches[3]', 'top');
}, 0, 0);