Use some good HTTP server library like libonion. Be sure to understand well HTTP.
Even if you have client side validation in JavaScript, don't trust it and repeat the validation on server side. An hostile user could send direct HTTP requests (outside of your AJAX).
Use session and cookies to identify (in the server) the various client browsers, and keep a separate environment (for your server-side interpreter) for each of them. Implement your re-entrant interpreter with isolation (of sessions and environments) in mind.
Containerization (with docker) is an extra security measure, but design your server side code to be secure (so check everything there) even without that.
If you have not read them already, read SICP, the Dragon Book, Lisp in Small Pieces, Programming language pragmatics, the GC handbook and this blog article, quite related in concepts (but with a very different terminology and approach, and indirectly related) to that one.
I want to make web REPL for my custom interpreter.
Then you could even take further inspiration from the 1980's Mentor system (and the related, even older, Centaur one). My Bismon draft report explains more how and why, but you need to abstract away from its title and skip its first few pages, required by European H2020 bureaucracy. My personal opinion about Mentor and Centaur is that the ideas described there are more than 25 years ahead of their time, and, given the power of current computers (1000x times better than in 1980s) it is worth resurrecting those old ideas. A probable major cause of the pragmatical and practical failure of those ideas is, I believe, the lack of computer power in 1980s era workstations.
PS. See also this.