# Need - neo4j reverse proxy config for apache

**URL:** <https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280>\
**Category:** Server\
**Created:** [January 9, 2019, 5:41pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280 "2019-01-09T17:41:18Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![njs8](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/njs8/32/2780_2.png) [@njs8](https://community.neo4j.com/u/njs8)\
**Post date:** [January 9, 2019, 5:41pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/1 "2019-01-09T17:41:18Z")

</div>

Can someone provide me with Apache reverse proxy config for neo4j. The browser is loading fine , but no luck connecting to the DB using the connect url.  
What should be the proxy config, specifically the one to connect to the Database.

This is my current Apache reverse config:

```auto
Redirect /neo4j /neo4j/

ProxyPass /neo4j/ http://hostname:7474/browser/

ProxyPassReverse /neo4j/ http://hostname:7474/browser/

```

and on the backend server where neo4j is installed and running, this is the only port thats listening

`tcp6 0 0 :::7474 :::* LISTEN 21202/java`

I can load the neo4j page from the web, but when I try to connect to the DB, I am getting ServiceUnavailable: Failed to fetch.

This is installed version - neo4j-3.5.1-1.noarch and the config file

dbms.directories.data=/var/lib/neo4j/data  
dbms.directories.plugins=/var/lib/neo4j/plugins  
dbms.directories.certificates=/var/lib/neo4j/certificates  
dbms.directories.logs=/var/log/neo4j  
dbms.directories.lib=/usr/share/neo4j/lib  
dbms.directories.run=/var/run/neo4j  
dbms.directories.import=/var/lib/neo4j/import  
dbms.connectors.default\_listen\_address=0.0.0.0  
dbms.connectors.default\_advertised\_address=localhost  
dbms.connector.bolt.enabled=true  
dbms.connector.http.enabled=true  
dbms.connector.https.enabled=true  
dbms.tx\_log.rotation.retention\_policy=1 days  
dbms.jvm.additional=-XX:+UseG1GC  
dbms.jvm.additional=-XX:-OmitStackTraceInFastThrow  
dbms.jvm.additional=-XX:+AlwaysPreTouch  
dbms.jvm.additional=-XX:+UnlockExperimentalVMOptions  
dbms.jvm.additional=-XX:+TrustFinalNonStaticFields  
dbms.jvm.additional=-XX:+DisableExplicitGC  
dbms.jvm.additional=-Djdk.tls.ephemeralDHKeySize=2048  
dbms.jvm.additional=-Djdk.tls.rejectClientInitiatedRenegotiation=true  
dbms.windows\_service\_name=neo4j  
dbms.jvm.additional=-Dunsupported.dbms.udc.source=rpm

Any help will be much appreciated

---

<div class="post-metadata">

**Author:** ![stefan.armbruster](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stefan.armbruster/32/74_2.png) [@stefan.armbruster](https://community.neo4j.com/u/stefan.armbruster)\
**Post date:** [January 9, 2019, 9:07pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/2 "2019-01-09T21:07:11Z")

</div>

Neo4j Browser uses a BOLT connection to your server's port 7687. I guess you need to proxy that as well. Be aware this port is not http, so you need a tcp proxy.

See e.g. [Using Nginx to proxy a Neo4j instance - Armbruster IT Blog](https://blog.armbruster-it.de/2018/05/using-nginx-to-proxy-a-neo4j-instance/)

---

<div class="post-metadata">

**Author:** ![njs8](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/njs8/32/2780_2.png) [@njs8](https://community.neo4j.com/u/njs8)\
**Post date:** [January 9, 2019, 9:22pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/3 "2019-01-09T21:22:41Z")

</div>

Hi Stefan,

I tried reverse proxying 7687. Everything work fine on the internal network. But from external network/internet - the neo4j browser page loads. But when I enter the Connect URL and try login in ..its failing..its not even hitting the proxy. Do you have a config file for apache?

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [January 9, 2019, 9:56pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/4 "2019-01-09T21:56:07Z")

</div>

you probably have to adapt the advertised address.  
can you check what it reports as bolt url in `curl http://hostname:7474/`

---

<div class="post-metadata">

**Author:** ![njs8](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/njs8/32/2780_2.png) [@njs8](https://community.neo4j.com/u/njs8)\
**Post date:** [January 10, 2019, 2:54pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/5 "2019-01-10T14:54:24Z")

</div>

Hi Michael,

This is what I get from the proxy host

curl [http://hdp004:7474/](http://hdp004:7474/)  
{  
"data" : "[http://hdp004:7474/db/data/](http://hdp004:7474/db/data/)",  
"management" : "[http://hdp004:7474/db/manage/](http://hdp004:7474/db/manage/)",  
"bolt" : "bolt://hdp004:7687"  
}

How should I configure apache reverse proxy config using the above endpoints? So that we can try hit it from the internet.

---

<div class="post-metadata">

**Author:** ![stefan.armbruster](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stefan.armbruster/32/74_2.png) [@stefan.armbruster](https://community.neo4j.com/u/stefan.armbruster)\
**Post date:** [January 10, 2019, 3:35pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/6 "2019-01-10T15:35:09Z")

</div>

try to set:

```auto
dbms.connectors.default_advertised_address=hdp004

```

---

<div class="post-metadata">

**Author:** ![njs8](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/njs8/32/2780_2.png) [@njs8](https://community.neo4j.com/u/njs8)\
**Post date:** [January 10, 2019, 3:36pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/7 "2019-01-10T15:36:46Z")

</div>

That what I have set in the config

dbms.directories.data=/var/lib/neo4j/data  
dbms.directories.plugins=/var/lib/neo4j/plugins  
dbms.directories.certificates=/var/lib/neo4j/certificates  
dbms.directories.logs=/var/log/neo4j  
dbms.directories.lib=/usr/share/neo4j/lib  
dbms.directories.run=/var/run/neo4j  
dbms.directories.import=/var/lib/neo4j/import  
dbms.connectors.default\_listen\_address=0.0.0.0  
**dbms.connectors.default\_advertised\_address=hdp004**  
dbms.connector.bolt.enabled=true  
dbms.connector.bolt.listen\_address=0.0.0.0:7687  
dbms.connector.http.enabled=true  
dbms.connector.https.enabled=false  
dbms.tx\_log.rotation.retention\_policy=1 days  
dbms.jvm.additional=-XX:+UseG1GC  
dbms.jvm.additional=-XX:-OmitStackTraceInFastThrow  
dbms.jvm.additional=-XX:+AlwaysPreTouch  
dbms.jvm.additional=-XX:+UnlockExperimentalVMOptions  
dbms.jvm.additional=-XX:+TrustFinalNonStaticFields  
dbms.jvm.additional=-XX:+DisableExplicitGC  
dbms.jvm.additional=-Djdk.tls.ephemeralDHKeySize=2048  
dbms.jvm.additional=-Djdk.tls.rejectClientInitiatedRenegotiation=true  
dbms.windows\_service\_name=neo4j  
dbms.jvm.additional=-Dunsupported.dbms.udc.source=rpm

---

<div class="post-metadata">

**Author:** ![stefan.armbruster](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stefan.armbruster/32/74_2.png) [@stefan.armbruster](https://community.neo4j.com/u/stefan.armbruster)\
**Post date:** [January 10, 2019, 5:05pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/8 "2019-01-10T17:05:47Z")

</div>

can you check javascript console in your browser for some suspicious messages?

---

<div class="post-metadata">

**Author:** ![njs8](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/njs8/32/2780_2.png) [@njs8](https://community.neo4j.com/u/njs8)\
**Post date:** [January 10, 2019, 5:50pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/9 "2019-01-10T17:50:54Z")

</div>

I am seeing this error when trying [http://portal.cac.queensu.ca](http://portal.cac.queensu.ca) in the connect url

Blocked loading mixed active content “[http://portal.cac.queensu.ca:7474/db/data/transaction](http://portal.cac.queensu.ca:7474/db/data/transaction)

and if I try just the url it showin -  
Firefox can’t establish a connection to the server at wss://portal.cac.queensu.ca:7687/

In Chrome these are the errors

vendors~main.chunkhash.bundle.js:86 Mixed Content: The page at '[Neo4j Browser](https://portal.cac.queensu.ca/neo4j/)' was loaded over HTTPS, but requested an insecure resource '[http://portal.cac.queensu.ca:7474/db/data/transaction](http://portal.cac.queensu.ca:7474/db/data/transaction)'. This request has been blocked; the content must be served over HTTPS.  
(anonymous) @ vendors~main.chunkhash.bundle.js:86  
e

If I try https  
vendors~main.chunkhash.bundle.js:86 OPTIONS [https://portal.cac.queensu.ca:7473/db/data/transaction](https://portal.cac.queensu.ca:7473/db/data/transaction) net::ERR\_CONNECTION\_REFUSED

If I try just the url -  
vendors~main.chunkhash.bundle.js:84 WebSocket connection to 'wss://portal.cac.queensu.ca:7687/' failed: Error in connection establishment: net::ERR\_CERT\_AUTHORITY\_INVALID

---

<div class="post-metadata">

**Author:** ![njs8](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/njs8/32/2780_2.png) [@njs8](https://community.neo4j.com/u/njs8)\
**Post date:** [February 14, 2019, 10:13pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/10 "2019-02-14T22:13:09Z")

</div>

Hello Team,

Any further updates on this.. I am still struggling to get this working over the web. Locally it works fine.

---

<div class="post-metadata">

**Author:** ![ftrotter](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ftrotter/32/3877_2.png) [@ftrotter](https://community.neo4j.com/u/ftrotter)\
**Post date:** [March 26, 2019, 6:19am UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/11 "2019-03-26T06:19:54Z")

</div>

Hey,  
This is a pretty important unanswered question that is the top result for Googling "using Neo4J browser with Apache".

Answering the question with a link to a tutorial about how to do this in nginx is not helpful and a little insulting. Many of us are still using apache for good reasons, so asking us to switch to nginx so that we can use neo4j is the same thing as saying "you cannot use neo4j web browser".

Also, trying to debug njs8 specific configuration is really not helpful. What is needed is a tutorial on how to set this up correctly on a fresh installation of Apache, on a fresh installation of neo4j, both on Ubuntu. Then njs8 could just see how his setup deviates from the working example. I do not understand why there not just a link to how to do this for both nginx and apache2 as part of the default documentation for neo4j. This is a super-common use case.

If it cannot be made to work.. fine.. then please tell us that. But lots of people need this configuration, so if this is merely a question of priorities.. well this is a show-stopper for me, and there are likely to be many people coming here from the google search with the same "show stopping" relationship with this configuration problem.

Regards,  
-FT

---

<div class="post-metadata">

**Author:** ![gautam.thakur](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gautam.thakur/32/4558_2.png) [@gautam.thakur](https://community.neo4j.com/u/gautam.thakur)\
**Post date:** [April 26, 2019, 2:06am UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/12 "2019-04-26T02:06:27Z")

</div>

Any luck with configuring neo4j behind apache, yet?

---

<div class="post-metadata">

**Author:** ![wunsch.kevin](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/wunsch.kevin/32/6181_2.png) [@wunsch.kevin](https://community.neo4j.com/u/wunsch.kevin)\
**Post date:** [April 28, 2020, 4:58pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/13 "2020-04-28T16:58:50Z")

</div>

Hi,  
I cannot set neo4j up using neither nginx nor apache...

are there any tutorials How-Tos available?

---

<div class="post-metadata">

**Author:** ![susan\_howe\_stan\_acco](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/susan_howe_stan_acco/32/18909_2.png) [@susan\_howe\_stan\_acco](https://community.neo4j.com/u/susan_howe_stan_acco)\
**Post date:** [July 1, 2021, 8:18pm UTC](https://community.neo4j.com/t/need-neo4j-reverse-proxy-config-for-apache/4280/14 "2021-07-01T20:18:51Z")

</div>

# A solution?

For folks who are still thinking about this years on, I have conceived of a _ **horrible no good very bad way** _ ™ of doing this which involves running two domains out of an Apache install. It works for a small project I'm doing over the summer with a _very_ limited number of people; I am sure that a brain much larger than mine would improve it. As such, here it is for good or ill.

## Context

The VPS on which I did this blocks many ports. I had to find a way to proxy the websocket/Bolt connection such that I could essentially connect to the same server from a remote connection _outside_ the network on which the server lives. This turned out to be complicated, as `/browser` is served on one of the few open ports. Because I setup an SSL on the server, that's two ports down (`80`, and `443`). Unfortunately, the last remaning open port, `22`, is reserved for SSH folderol. This was a major limitation that spurred this solution.

## Ok, just get to the goods

If you came here for configs -- go no further. However, this mess probably needs a bit of qualification. Read on!

```auto
SSLStrictSNIVHostCheck On

ServerName sub.subdomain.domain.com

<IfModule mod_ssl.c>
<VirtualHost *:443>

	ServerAdmin me@email.com
	ServerName subdomain.domain.com

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	<Location /browser>
		ProxyPreserveHost On
		ProxyPass http://localhost:7474/browser
		ProxyPassReverse http://localhost:7474/browser

		RewriteEngine On

		RewriteCond %{REQUEST_URI} !^/browser
		RewriteRule ^/$ /browser/$1 [R,L]
	</Location>	

	# Let's Encrypt SSL stuff
	# Let's Encrypt SSL stuff
	# Let's Encrypt SSL stuff
	# Let's Encrypt SSL stuff
	
</VirtualHost>
</IfModule>

<IfModule mod_ssl.c>
<VirtualHost *:443>
	ServerAdmin me@email.com
	ServerName sub.subdomain.domain.com

	ErrorLog ${APACHE_LOG_DIR}/db_error.log
	CustomLog ${APACHE_LOG_DIR}/db_access.log combined

	RewriteEngine On
    RewriteCond %{HTTP:Connection} Upgrade [NC]
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteRule /?(.*) wss://localhost:7687/$1 [P,L]

	SSLProxyEngine On
	SSLProxyCheckPeerCN off
	ProxyPassReverseCookieDomain "/" "sub.subdomain.domain.com"

    ProxyPreserveHost off
    ProxyPass / http://localhost:7687/
    ProxyPassReverse / http://localhost:7687/

	# Let's Encrypt SSL stuff
	# Let's Encrypt SSL stuff
	# Let's Encrypt SSL stuff
	# Let's Encrypt SSL stuff
	
</VirtualHost>
</IfModule>

```

The concept here is that I can access the HTTPS port of `sub.subdomain.domain.com` from `subdomain.domain.com`. Adding SSL configuration to neo4j ([discussed here](https://community.neo4j.com/t/remote-neo4j-server-port-7474-connection-refused/30058/3)) ensures that the websockets don't run afoul of security policy. Due to this proxy, we also have to connect on `sub.subdomain.domain.com:443` as our `bolt+s://` connection.

There's probably a more elegant expression of this, but the idea surprisingly works.
