简体   繁体   中英

Reverse proxy from apache server to mongodb

I have an apache server running, and on this server I have a mongo database running too, listening on standard port 27017.

Is there a way to make a reverse proxy in apache configuration to send requests to my mongo database ?

I tried this, but it doesn't seem to works at all :

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName *********

    # DocumentRoot /var/www/test

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

    ProxyPreserveHost On
    ProxyPass / http://localhost:27017/
    ProxyPassReverse / http://localhost:27017/
</VirtualHost>

Your requirement needs a TCP proxy and not a HTTP proxy which you are trying to do using Apache. You can use software based like nginx or squid as TCP proxy server or by using pure NAT configuration based on iptables also is possible.

Couple of answers which can help you. TCP proxy mongodb with nginx proxy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM