There are cases when you want to access your Neo4j instance remotely and you live in an environment where direct access is not possible. This might be caused by technical or organizational restrictions.
One generic solution to this kind of problems is using a VPN. Another alternative to be discussed in this blog post is using a reverse proxy server. I want to show how you can proxy Neo4j using Nginx.
First of all run a neo4j instance. In order to not have false positive results I’m using non-standard ports for http (default 7474, using 17474 here) and bolt (default 7687, using 17687 here). Spinning up a test instance is easy in docker:
1 |
docker run --rm -e NEO4J_AUTH=none -p 17474:7474 -p 17687:7687 neo4j |
Note that I’ve switched off authentication, something that might be ok for testing, but is a clear no-go for any other kind of usage.
I’m installing Nginx directly on my system:
1 |
apt install nginx |
Then we need to map both communication channels: http and bolt. For the http part we add inside the server
section of /etc/nginx/sites-available/default
this snippet:
1 |
location /browser/ {<br /> proxy_pass http://localhost:17474/; # <-- replace with your neo4j instance's http servername + port<br /> } |
For the bolt protocol we amend to /etc/nginx/nginx.conf
:
1 2 |
stream { server {<br /> listen 7687;<br /> proxy_pass localhost:17687; # <--- replace this with your neo4j server and bolt port<br /> }<br />} |
After a restart of nginx pointing your browser to http://localhost/browser should show up the neo4j browser.